CompareWith function hangs

RawdenRawden Posts: 34 Bronze 2
Hi,

We have been using the following project to update our customer's DBs for a while now.

Download URL:
https://dl.dropboxusercontent.com/u/31635940/UpdateSchemaFromSnapshot.zip

Yesterday I loaded the SQL Compare application and it prompted that there were updates available, so I installed 10.7.0.18

Since then, (I'm not sure if it's related or not) the project in the zip file above is getting stuck when running the following line:
tblDiffs = dbSource.CompareWith(dbDest, Opts)
How can I check which version of the SDK I have installed.... or if there is a newer one?

Comments

  • Hmm. It's possible you're running afoul of a few of the changes introduced in the Comparison SDK version 10.5 - we've got an article up about those here: https://documentation.red-gate.com/disp ... n+SDK+10.5

    Specifically, in previous versions of the SQL Comparison SDK, comparison options were specified as a bit flags enum, like:
    Options.Default | Options.DropAndCreateInsteadOfAlter
    
    In version 10.5, options are specified using the methods in the Options class, like:
    Options.Default.Plus(Options.DropAndCreateInsteadOfAlter)
    
    or
    Options.Default.Except(Options.IgnoreFileGroups, Options.IgnoreComments)
    

    Hope that helps!
    Andy Campbell Smith

    Red Gate Technical Support Engineer
  • RawdenRawden Posts: 34 Bronze 2
    Hi Andy,

    Thanks for the reply. Very useful, but I'm pretty sure I'm doing all those things.

    I've got a reference to RedGate.Shared.ComparisonInterfaces

    I've changed my uses of 'DifferenceType'

    I've tried the app with various option settings. Even just the default ones:
    Dim Ops As New RedGate.SQLCompare.Engine.Options
    
                Ops = RedGate.SQLCompare.Engine.Options.Default
                tblDiffs = dbSource.CompareWith(dbDest, Ops)
    

    Did you manage to open my example project at all? You'd need to change the project's command-line arguments to point it to a test DB you have available. You'll also need to drop a snapshot file called snapshot.snp into the bin\debug folder.

    I have tried this with multiple databases they all get stuck on that line. This was working fine before I updated the SQL Compare app the other day.

    Kind Regards,

    Rawden.
  • RawdenRawden Posts: 34 Bronze 2
    Hi Andy,

    Just wondered if you'd had any further joy?

    Regards,

    Rawden.
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    I can't quite find the root cause, but I can point you in the right direction...

    Something in the CompareWith method is being held up by a deadlock in the UI thread.

    If you look at the stacks for all threads, you can see the SDK code is waiting for the WaitHandle to be set, meanwhile you see multiple threads with waits fired by your StatusCallback sub.

    If you comment out the entire StatusCallback sub, the code will run past the first status update fired by SDK. I am guessing you should check to see if you have InvokeRequired in that method?
    Attached to pid:8460
    
    Thread 10916 [Status=Wait UserTime=4274 Wait Reason=UserRequest]
    Callstack for Thread 10916
     System.Threading.Monitor.Wait(System.Object,System.Int32,System.Boolean)
     System.Threading.Monitor.Wait(System.Object,System.Int32)
     System.Threading.ManualResetEventSlim.Wait(System.Threading.ManualResetEventSlim,System.Int32,System.Threading.CancellationToken)
     System.Threading.ManualResetEventSlim.Wait(System.Threading.ManualResetEventSlim)
     System.Threading.Tasks.Task.InternalRunSynchronously(System.Threading.Tasks.ParallelForReplicatingTask,System.Threading.Tasks.ThreadPoolTaskScheduler)
     System.Threading.Tasks.Task.RunSynchronously(System.Threading.Tasks.ParallelForReplicatingTask,System.Threading.Tasks.ThreadPoolTaskScheduler)
     System.Threading.Tasks.Parallel.PartitionerForEachWorker(System.Collections.Concurrent.Partitioner.DynamicPartitionerForIEnumerable`1<RedGate.SQLCompare.Engine.IDatabaseObject>,System.Threading.Tasks.ParallelOptions,System.Action`1<RedGate.SQLCompare.Engine.IDatabaseObject>,System.Action`2<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState>,System.Action`3<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState,System.Int64>,System.Func`4<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState,System.Object,System.Object>,System.Func`5<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState,System.Int64,System.Object,System.Object>,System.Func`1<System.Object>,System.Action`1<System.Object>)
     System.Threading.Tasks.Parallel.ForEachWorker(System.Linq.Enumerable.<OfTypeIterator>d__a3`1<RedGate.SQLCompare.Engine.IDatabaseObject>,System.Threading.Tasks.ParallelOptions,System.Action`1<RedGate.SQLCompare.Engine.IDatabaseObject>,System.Action`2<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState>,System.Action`3<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState,System.Int64>,System.Func`4<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState,System.Object,System.Object>,System.Func`5<RedGate.SQLCompare.Engine.IDatabaseObject,System.Threading.Tasks.ParallelLoopState,System.Int64,System.Object,System.Object>,System.Func`1<System.Object>,System.Action`1<System.Object>)
     System.Threading.Tasks.Parallel.ForEach(System.Linq.Enumerable.<OfTypeIterator>d__a3`1<RedGate.SQLCompare.Engine.IDatabaseObject>,System.Threading.Tasks.ParallelOptions,System.Action`1<RedGate.SQLCompare.Engine.IDatabaseObject>)
     #Cjmd.#Wkqd.#Rkqd(#Cjmd.#Wkqd,RedGate.SQLCompare.Engine.Differences,RedGate.SQLCompare.Engine.Tables,RedGate.SQLCompare.Engine.Tables,RedGate.SQLCompare.Engine.Options,RedGate.Shared.SQL.Server.SQLVersion,#8rg.#uug,#8rg.#yvg)
     #Cjmd.#Wkqd.#Rkqd(#Cjmd.#Wkqd,RedGate.SQLCompare.Engine.Differences,#8rg.#AHud)
     #8rg.#AHud.CompareWith(#8rg.#AHud,#8rg.#AHud,RedGate.SQLCompare.Engine.Options,RedGate.SQLCompare.Engine.SqlCompareOwnerMappings,RedGate.SQLCompare.Engine.SqlCompareTableMappings)
     #8rg.#AHud.CompareWith(#8rg.#AHud,#8rg.#AHud,RedGate.SQLCompare.Engine.Options,RedGate.SQLCompare.Engine.SqlCompareOwnerMappings)
     #8rg.#AHud.CompareWith(#8rg.#AHud,#8rg.#AHud,RedGate.SQLCompare.Engine.Options)
     RedGate.SQLCompare.Engine.Database.CompareWith(RedGate.SQLCompare.Engine.Database,RedGate.SQLCompare.Engine.Database,RedGate.SQLCompare.Engine.Options)
     UpdateSchemaFromSnapshot.clsRedgateSchemaCompare.StartSchemaCompare(UpdateSchemaFromSnapshot.clsRedgateSchemaCompare) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\clsRedgateSchema.vb:182
     UpdateSchemaFromSnapshot.frmMain.tmrLoad_Tick(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.Timer,System.EventArgs) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:614
     System.Windows.Forms.Timer.OnTick(System.Windows.Forms.Timer,System.EventArgs)
     System.Windows.Forms.Timer.TimerNativeWindow.WndProc(System.Windows.Forms.Timer.TimerNativeWindow,System.Windows.Forms.Message&)
     System.Windows.Forms.NativeWindow.DebuggableCallback(System.Windows.Forms.Timer.TimerNativeWindow,System.IntPtr,System.Int32,System.IntPtr,System.IntPtr)
     <No code for this function> System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW()
     System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.Windows.Forms.Application.ComponentManager,System.Int32,System.Int32,System.Int32)
     System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(System.Windows.Forms.Application.ThreadContext,System.Int32,Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.WinFormsAppContext)
     System.Windows.Forms.Application.ThreadContext.RunMessageLoop(System.Windows.Forms.Application.ThreadContext,System.Int32,Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.WinFormsAppContext)
     System.Windows.Forms.Application.Run(Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.WinFormsAppContext)
     Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun(UpdateSchemaFromSnapshot.My.MyApplication)
     Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel(UpdateSchemaFromSnapshot.My.MyApplication)
     Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(UpdateSchemaFromSnapshot.My.MyApplication,System.String[])
     UpdateSchemaFromSnapshot.My.MyApplication.Main(System.String[]) 17d14f5c-a337-4978-8281-53493378c1071.vb:82
    
    Thread 4548 [Status=Wait UserTime=0 Wait Reason=UserRequest]
    Callstack for Thread 4548
    
    Thread 5332 [Status=Wait UserTime=670 Wait Reason=UserRequest]
    Callstack for Thread 5332
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int64,System.Boolean)
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int32,System.Boolean)
     System.Windows.Forms.Control.WaitForWaitHandle(UpdateSchemaFromSnapshot.frmMain,System.Threading.ManualResetEvent)
     System.Windows.Forms.Control.EndInvoke(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.Control.ThreadMethodEntry)
     UpdateSchemaFromSnapshot.frmMain.AddStatusText(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.RichTextBox,System.String,UpdateSchemaFromSnapshot.clsRedgateSchemaCompare.StatusType,System.Drawing.Color) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:98
     UpdateSchemaFromSnapshot.frmMain.StatusCallback(UpdateSchemaFromSnapshot.frmMain,#8rg.#AHud,RedGate.Shared.Utils.StatusEventArgs) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:159
     System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(System.Runtime.Remoting.Messaging.StackBuilderSink,System.RuntimeMethodHandle,System.Object[],UpdateSchemaFromSnapshot.frmMain,System.Int32,System.Boolean,System.Object[]&)
     System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.StackBuilderSink,System.Runtime.Remoting.Messaging.MethodCall,System.Runtime.Remoting.Messaging.AsyncResult)
     System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall(System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem)
     System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem)
     System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
    
    Thread 5708 [Status=Wait UserTime=31 Wait Reason=UserRequest]
    Callstack for Thread 5708
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int64,System.Boolean)
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int32,System.Boolean)
     System.Windows.Forms.Control.WaitForWaitHandle(UpdateSchemaFromSnapshot.frmMain,System.Threading.ManualResetEvent)
     System.Windows.Forms.Control.EndInvoke(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.Control.ThreadMethodEntry)
     UpdateSchemaFromSnapshot.frmMain.SetProgressBar(UpdateSchemaFromSnapshot.frmMain,System.Int32) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:182
     UpdateSchemaFromSnapshot.frmMain.StatusCallback(UpdateSchemaFromSnapshot.frmMain,#8rg.#AHud,RedGate.Shared.Utils.StatusEventArgs) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:168
     #8rg.#yvg.#lzh(#8rg.#yvg)
     #8rg.#yvg.#QVb(#8rg.#yvg)
     #Cjmd.#Wkqd.#Jjmd(#Cjmd.#Wkqd,RedGate.SQLCompare.Engine.Differences,RedGate.SQLCompare.Engine.Tables,RedGate.SQLCompare.Engine.Options,RedGate.Shared.SQL.Server.SQLVersion,#8rg.#uug,RedGate.SQLCompare.Engine.Table,#8rg.#yvg)
     #Cjmd.#Wkqd.#sZe.#6kqd(#Cjmd.#Wkqd.#sZe<RedGate.SQLCompare.Engine.Table>,RedGate.SQLCompare.Engine.Table)
     System.Threading.Tasks.Parallel.<>c__DisplayClass32`2.<PartitionerForEachWorker>b__30(System.Threading.Tasks.Parallel.<>c__DisplayClass32`2<RedGate.SQLCompare.Engine.IDatabaseObject,System.Object>)
     System.Threading.Tasks.Task.InnerInvoke(System.Threading.Tasks.ParallelForReplicatingTask)
     System.Threading.Tasks.Task.InnerInvokeWithArg(System.Threading.Tasks.ParallelForReplicatingTask,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.<>c__DisplayClass3.<ExecuteSelfReplicating>b__2(System.Threading.Tasks.Task.<>c__DisplayClass3,System.Object)
     System.Threading.Tasks.Task.InnerInvoke(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.Execute(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.ExecutionContextCallback(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.ParallelForReplicaTask,System.Threading.Tasks.Task&)
     System.Threading.Tasks.Task.ExecuteEntry(System.Threading.Tasks.ParallelForReplicaTask,System.Boolean)
     System.Threading.Tasks.ThreadPoolTaskScheduler.TaskExecuteWaitCallback(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
    
    Thread 5404 [Status=Wait UserTime=46 Wait Reason=UserRequest]
    Callstack for Thread 5404
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int64,System.Boolean)
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int32,System.Boolean)
     System.Windows.Forms.Control.WaitForWaitHandle(UpdateSchemaFromSnapshot.frmMain,System.Threading.ManualResetEvent)
     System.Windows.Forms.Control.EndInvoke(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.Control.ThreadMethodEntry)
     UpdateSchemaFromSnapshot.frmMain.SetProgressBar(UpdateSchemaFromSnapshot.frmMain,System.Int32) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:182
     UpdateSchemaFromSnapshot.frmMain.StatusCallback(UpdateSchemaFromSnapshot.frmMain,#8rg.#AHud,RedGate.Shared.Utils.StatusEventArgs) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:168
     #8rg.#yvg.#lzh(#8rg.#yvg)
     #8rg.#yvg.#QVb(#8rg.#yvg)
     #Cjmd.#Wkqd.#Jjmd(#Cjmd.#Wkqd,RedGate.SQLCompare.Engine.Differences,RedGate.SQLCompare.Engine.Tables,RedGate.SQLCompare.Engine.Options,RedGate.Shared.SQL.Server.SQLVersion,#8rg.#uug,RedGate.SQLCompare.Engine.Table,#8rg.#yvg)
     #Cjmd.#Wkqd.#sZe.#6kqd(#Cjmd.#Wkqd.#sZe<RedGate.SQLCompare.Engine.Table>,RedGate.SQLCompare.Engine.Table)
     System.Threading.Tasks.Parallel.<>c__DisplayClass32`2.<PartitionerForEachWorker>b__30(System.Threading.Tasks.Parallel.<>c__DisplayClass32`2<RedGate.SQLCompare.Engine.IDatabaseObject,System.Object>)
     System.Threading.Tasks.Task.InnerInvoke(System.Threading.Tasks.ParallelForReplicatingTask)
     System.Threading.Tasks.Task.InnerInvokeWithArg(System.Threading.Tasks.ParallelForReplicatingTask,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.<>c__DisplayClass3.<ExecuteSelfReplicating>b__2(System.Threading.Tasks.Task.<>c__DisplayClass3,System.Object)
     System.Threading.Tasks.Task.InnerInvoke(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.Execute(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.ExecutionContextCallback(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.ParallelForReplicaTask,System.Threading.Tasks.Task&)
     System.Threading.Tasks.Task.ExecuteEntry(System.Threading.Tasks.ParallelForReplicaTask,System.Boolean)
     System.Threading.Tasks.ThreadPoolTaskScheduler.TaskExecuteWaitCallback(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
    
    Thread 5400 [Status=Wait UserTime=0 Wait Reason=UserRequest]
    Callstack for Thread 5400
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int64,System.Boolean)
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int32,System.Boolean)
     System.Windows.Forms.Control.WaitForWaitHandle(UpdateSchemaFromSnapshot.frmMain,System.Threading.ManualResetEvent)
     System.Windows.Forms.Control.EndInvoke(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.Control.ThreadMethodEntry)
     UpdateSchemaFromSnapshot.frmMain.AddStatusText(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.RichTextBox,System.String,UpdateSchemaFromSnapshot.clsRedgateSchemaCompare.StatusType,System.Drawing.Color) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:98
     UpdateSchemaFromSnapshot.frmMain.StatusCallback(UpdateSchemaFromSnapshot.frmMain,#8rg.#AHud,RedGate.Shared.Utils.StatusEventArgs) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:159
     System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(System.Runtime.Remoting.Messaging.StackBuilderSink,System.RuntimeMethodHandle,System.Object[],UpdateSchemaFromSnapshot.frmMain,System.Int32,System.Boolean,System.Object[]&)
     System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.StackBuilderSink,System.Runtime.Remoting.Messaging.MethodCall,System.Runtime.Remoting.Messaging.AsyncResult)
     System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall(System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem)
     System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem)
     System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
    
    Thread 6860 [Status=Wait UserTime=0 Wait Reason=UserRequest]
    Callstack for Thread 6860
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int64,System.Boolean)
     System.Threading.WaitHandle.WaitOne(System.Threading.ManualResetEvent,System.Int32,System.Boolean)
     System.Windows.Forms.Control.WaitForWaitHandle(UpdateSchemaFromSnapshot.frmMain,System.Threading.ManualResetEvent)
     System.Windows.Forms.Control.EndInvoke(UpdateSchemaFromSnapshot.frmMain,System.Windows.Forms.Control.ThreadMethodEntry)
     UpdateSchemaFromSnapshot.frmMain.SetProgressBar(UpdateSchemaFromSnapshot.frmMain,System.Int32) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:182
     UpdateSchemaFromSnapshot.frmMain.StatusCallback(UpdateSchemaFromSnapshot.frmMain,#8rg.#AHud,RedGate.Shared.Utils.StatusEventArgs) D:\work\casework\Z19702\UpdateSchemaFromSnapshot\frmMain.vb:168
     #8rg.#yvg.#lzh(#8rg.#yvg)
     #8rg.#yvg.#QVb(#8rg.#yvg)
     #Cjmd.#Wkqd.#Jjmd(#Cjmd.#Wkqd,RedGate.SQLCompare.Engine.Differences,RedGate.SQLCompare.Engine.Tables,RedGate.SQLCompare.Engine.Options,RedGate.Shared.SQL.Server.SQLVersion,#8rg.#uug,RedGate.SQLCompare.Engine.Table,#8rg.#yvg)
     #Cjmd.#Wkqd.#sZe.#6kqd(#Cjmd.#Wkqd.#sZe<RedGate.SQLCompare.Engine.Table>,RedGate.SQLCompare.Engine.Table)
     System.Threading.Tasks.Parallel.<>c__DisplayClass32`2.<PartitionerForEachWorker>b__30(System.Threading.Tasks.Parallel.<>c__DisplayClass32`2<RedGate.SQLCompare.Engine.IDatabaseObject,System.Object>)
     System.Threading.Tasks.Task.InnerInvoke(System.Threading.Tasks.ParallelForReplicatingTask)
     System.Threading.Tasks.Task.InnerInvokeWithArg(System.Threading.Tasks.ParallelForReplicatingTask,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.<>c__DisplayClass3.<ExecuteSelfReplicating>b__2(System.Threading.Tasks.Task.<>c__DisplayClass3,System.Object)
     System.Threading.Tasks.Task.InnerInvoke(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.Execute(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.ExecutionContextCallback(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.ParallelForReplicaTask,System.Threading.Tasks.Task&)
     System.Threading.Tasks.Task.ExecuteEntry(System.Threading.Tasks.ParallelForReplicaTask,System.Boolean)
     System.Threading.Tasks.ThreadPoolTaskScheduler.TaskExecuteWaitCallback(System.Threading.Tasks.ParallelForReplicaTask)
     System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.runTryCode(System.Threading.ExecutionContext.ExecutionContextRunData)
     System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
     System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
    
    Thread 6896 [Status=Wait UserTime=15 Wait Reason=UserRequest]
    Callstack for Thread 6896
    
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    I was right. It will not hang if you check for invoke required.
    'Add the following delegate function
    Public Delegate Sub SafetyDelegate(ByVal sender As Object, ByVal e As RedGate.Shared.Utils.StatusEventArgs)
        Sub StatusCallback(ByVal sender As Object, ByVal e As RedGate.Shared.Utils.StatusEventArgs)
    'Check for InvokeRequired
            If Me.InvokeRequired Then
                Me.BeginInvoke(New SafetyDelegate(AddressOf StatusCallback), sender, e)
                Return
            End If
    ' Now we resume your regularly-scheduled program.
            If Not (e.Message Is Nothing) Then
    
                'If Me.chkShowFullDetails.Checked = True Then
                Me.AddStatusText(Me.rtxtHidden, e.Message, StatusType.SmallText, Color.Black)
                'Application.DoEvents()
                'End If
            End If
    
            If e.Message <> "" Then UpdateStatusText(e.Message)
    
            If e.Percentage > -1 And e.Percentage <= 100 Then
    
                'frmMDIStatus.SetProgressBar(e.Percentage)
    
                Me.SetProgressBar(e.Percentage)
            End If
    
        End Sub
    
  • RawdenRawden Posts: 34 Bronze 2
    Thank you Brian.

    I thought it was covered, as I was invoke checking in all the methods called by the StatusCallback sub (UpdateStatusText, SetProgressBar & AddStatusText)
Sign In or Register to comment.