6

I have "Run each query in its own process" option turned on (default value), but it seems that the process is being reused between query runs (LINQPad.UserQuery.exe keeps running).

Is there a way to avoid this reuse? I need a fresh process every time (due to JVM usage).

Obvious way is

Environment.Exit(0);

but it results in unpleasant "Query ended unexpectedly" message.

Pavel Tupitsyn
  • 8,393
  • 3
  • 22
  • 44

2 Answers2

7

Try Util.NewProcess = true:

Util.NewProcess = true;
Process.GetCurrentProcess().Id.Dump();

Also you can try option from menu: 'Query' -> 'Cancel All Threads and Reset' (also available via shortcut Shift+Control+F5)

Guru Stron
  • 102,774
  • 10
  • 95
  • 132
7

The option "Run each query in its own process" instructs LINQPad to use process isolation rather than AppDomain isolation. It will still re-use the process if you re-run the same query.

The option you want is "Always use fresh application domains". Set this to true, and you'll get a fresh process/AppDomain with each execution. Or, as the Guru suggested, set Util.NewProcess in your query. This forces the next execution to use a fresh process/domain.

Joe Albahari
  • 30,118
  • 7
  • 80
  • 91
  • Thank you, Joe! Since I'm creating a NuGet package with samples for our framework, Util.NewProcess seems to be the best way, so the users won't have to change their settings. – Pavel Tupitsyn Feb 18 '16 at 07:10