Exemple #1
0
 private void StartQuery(QueryRunner runner)
 {
     object obj2;
     lock ((obj2 = this._statusLocker))
     {
         if (this._cancelRequest)
         {
             return;
         }
     }
     _currentServer = this;
     this.ServerThread = Thread.CurrentThread;
     if ((this._repository != null) && this._repository.DriverLoader.IsValid)
     {
         this._dataContextDriver = this._repository.DriverLoader.Driver;
     }
     if ((this._dataContextDriver is EntityFrameworkDriver) || (this._dataContextDriver is EntityFrameworkDbContextDriver))
     {
         this.InstallDbProviders(this._repository);
     }
     lock ((obj2 = this._statusLocker))
     {
         if (this._cancelRequest)
         {
             return;
         }
     }
     if (_domainExceptionHandler != null)
     {
         System.AppDomain.CurrentDomain.UnhandledException -= _domainExceptionHandler;
     }
     System.AppDomain.CurrentDomain.UnhandledException += (_domainExceptionHandler = new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException));
     try
     {
         this.RunQuery(runner);
     }
     catch (ThreadAbortException)
     {
     }
     catch (Exception exception)
     {
         this.MessageLoopEnded = true;
         this.PostStatus(this.GetStatusArgs(exception, true, true));
         this.PerformCompletionCleanup(true, false);
         this.PerformFinalCleanup();
     }
 }
Exemple #2
0
 private void RunQuery(QueryRunner runner)
 {
     Action<Task> continuationAction = null;
     Action a = null;
     object obj2;
     runner.Prepare();
     this.QueryCompletionCountdown = new Countdown();
     this.Disposables = new List<IDisposable>();
     this.LambdaFormatter = new XhtmlWriter(false, false);
     LINQPadDbController.SqlLog = new StringWriterEx(0xf4240);
     DataContextBase.SqlLog = LINQPadDbController.SqlLog;
     this.ResultsWriter = new XhtmlWriter(true, true);
     this._explorables = this.ResultsWriter.Explorables;
     Console.SetOut(this.ResultsWriter);
     Console.SetIn(new ConsoleTextReader(new Func<string>(this.ReadLine)));
     Debug.Listeners.Clear();
     Debug.Listeners.Add(new TextWriterTraceListener(this.ResultsWriter));
     XhtmlFormatter.ResetTableID();
     lock ((obj2 = this._statusLocker))
     {
         if (this._cancelRequest)
         {
             return;
         }
     }
     object obj3 = null;
     try
     {
         obj3 = runner.Run();
     }
     catch (Exception exception)
     {
         this.PostStatus(this.GetStatusArgs(exception, false, true));
     }
     if (obj3 is Task)
     {
         this.QueryCompletionCountdown.Increment();
         QueryStatusEventArgs args = new QueryStatusEventArgs("Query continuing asynchronously...") {
             ExecutionComplete = false,
             Async = true
         };
         this.PostStatus(args);
         if (continuationAction == null)
         {
             continuationAction = delegate (Task ant) {
                 try
                 {
                     Exception ex = this.GetTaskException(ant);
                     if (ex != null)
                     {
                         this._faulted = true;
                         this.PostStatus(this.GetStatusArgs(ex, true, true));
                     }
                 }
                 catch
                 {
                 }
                 this.QueryCompletionCountdown.Decrement();
             };
         }
         ((Task) obj3).ContinueWith(continuationAction);
     }
     if (this.QueryCompletionCountdown.Value <= 0)
     {
         this._executionStopwatch.Stop();
     }
     lock ((obj2 = this._statusLocker))
     {
         if (this._cancelRequest)
         {
             return;
         }
     }
     PluginForm pluginForm = null;
     pluginForm = this.PrepareMessageLoop();
     if (pluginForm != null)
     {
         this.QueryCompletionCountdown.Increment();
     }
     if (this.QueryCompletionCountdown.Value <= 0)
     {
         this.PostStatus(this.GetStatusArgs(null, true, true));
         this.PerformCompletionCleanup(false, false);
     }
     else
     {
         QueryStatusEventArgs args2 = new QueryStatusEventArgs("Query continuing asynchronously...") {
             ExecutionComplete = false,
             Async = true
         };
         this.PostStatus(args2);
         if (a == null)
         {
             a = delegate {
                 this.PostStatus(this.GetStatusArgs(null, true, true));
                 this.PerformCompletionCleanup(false, false);
             };
         }
         this.QueryCompletionCountdown.ContinueWith(a);
     }
     this.RunMessageLoop(pluginForm, true);
 }