internal void Start(DataContextCallback callback, SchemaChangeTestMode schemaTestMode)
 {
     ThreadStart start = null;
     bool flag = false;
     lock (this._locker)
     {
         this._lastUsed = DateTime.UtcNow;
         if (callback != null)
         {
             this._oneOffSubscribers = (DataContextCallback) Delegate.Combine(this._oneOffSubscribers, callback);
         }
         if (!(this._busy && (schemaTestMode != SchemaChangeTestMode.ForceRefresh)))
         {
             this._busy = flag = true;
             this._error = null;
             this._status = "Connecting";
         }
         if (flag)
         {
             if (start == null)
             {
                 start = () => this.GetDCInfo(schemaTestMode);
             }
             Thread thread = new Thread(start) {
                 IsBackground = true,
                 Name = "DataContext Refresh",
                 Priority = ThreadPriority.BelowNormal
             };
             this._worker = thread;
             this._worker.Start();
         }
     }
 }
 private void GetDCInfo(SchemaChangeTestMode schemaTestMode)
 {
     Exception exception;
     bool flag = true;
     try
     {
         object obj2;
         try
         {
             bool flag2;
             if (this._disposed)
             {
                 return;
             }
             if (!((flag2 = (this._schema == null) || (schemaTestMode == SchemaChangeTestMode.ForceRefresh)) || (schemaTestMode == SchemaChangeTestMode.None)))
             {
                 bool? nullable = this.HasSchemaChanged();
                 flag2 = nullable.HasValue ? nullable.GetValueOrDefault() : (schemaTestMode == SchemaChangeTestMode.TestAndFailPositive);
             }
             if (flag2)
             {
                 this.UpdateSchema();
             }
             else
             {
                 flag = false;
             }
             if (this._lastSchemaChange == new DateTime())
             {
                 this.HasSchemaChanged();
             }
         }
         catch (Exception exception1)
         {
             exception = exception1;
             if (!(!this._repository.DriverLoader.IsInternalAuthor || IsUserError(exception)))
             {
                 Program.ProcessException(exception);
             }
             else
             {
                 Log.Write(exception, "Error opening DataContext");
             }
             lock ((obj2 = this._locker))
             {
                 if (this._worker == Thread.CurrentThread)
                 {
                     this._error = (exception is AccessViolationException) ? "An AccessViolationException was thrown when trying to open the connection." : exception.Message;
                     this._repository.IsAutoGenAssemblyAvailable = false;
                     this._repository.AutoGenAssemblyFailed = true;
                 }
             }
         }
         Delegate[] invocationList = null;
         Delegate[] delegateArray2 = null;
         DataContextInfo dCInfo = null;
         lock ((obj2 = this._locker))
         {
             if (this._worker != Thread.CurrentThread)
             {
                 return;
             }
             this._status = "";
             this._busy = false;
             dCInfo = this.GetDCInfo();
             if (flag && (this._changeSubscribers != null))
             {
                 invocationList = this._changeSubscribers.GetInvocationList();
                 foreach (DataContextCallback callback in this._changeSubscribers.GetInvocationList())
                 {
                     if (this._oneOffSubscribers == null)
                     {
                         break;
                     }
                     this._oneOffSubscribers = (DataContextCallback) Delegate.Remove(this._oneOffSubscribers, callback);
                 }
             }
             if (this._oneOffSubscribers != null)
             {
                 delegateArray2 = this._oneOffSubscribers.GetInvocationList();
             }
             this._oneOffSubscribers = null;
         }
         if (invocationList != null)
         {
             foreach (DataContextCallback callback2 in invocationList)
             {
                 callback2(dCInfo);
             }
         }
         if (delegateArray2 != null)
         {
             foreach (DataContextCallback callback2 in delegateArray2)
             {
                 callback2(dCInfo);
             }
         }
         if (dCInfo.Error != null)
         {
             DataContextManager._globalErrorHandlers(dCInfo);
         }
     }
     catch (Exception exception2)
     {
         exception = exception2;
         Program.ProcessException(exception);
     }
 }
 public static void RefreshDataContextInfo(LINQPad.Repository r, SchemaChangeTestMode schemaTestMode)
 {
     if (schemaTestMode == SchemaChangeTestMode.None)
     {
         throw new ArgumentException("schemaTestMode cannot be None when calling RefreshDataContextInfo");
     }
     GetDataContextInfo(r, null, schemaTestMode);
 }
 public static void GetDataContextInfo(LINQPad.Repository r, DataContextCallback callback, SchemaChangeTestMode schemaTestMode)
 {
     DataContextManager manager = new DataContextManager(r, null);
     DataContextCallback callback2 = delegate (DataContextInfo info) {
         manager.Dispose();
         if (callback != null)
         {
             callback(info);
         }
     };
     if (!((callback != null) || manager.HasOtherSubscribers))
     {
         manager.Dispose();
     }
     else
     {
         manager.GetDataContextInfo(callback2, schemaTestMode);
     }
 }
 private void GetDataContextInfo(DataContextCallback callback, SchemaChangeTestMode schemaTestMode)
 {
     this._runner.Start(callback, schemaTestMode);
 }
 public void GetDataContextInfo(SchemaChangeTestMode schemaTestMode)
 {
     this.GetDataContextInfo(this._subscription, schemaTestMode);
 }