TRACE FREEZES CURRENT CONTEXT
Hello,
I have troubles when using
SMO trace event. I can start trace in windows application (not console application) but window is frozen it does not allow you to play with controls in the window. I use
Thread.Slep event but still doesn't work window cursor is cursor.wait. Does anybody know how can I unfreeze window while trace event occur.(like SQL profiler window)
Hello,
Below you will find what I am trying to do.
***********************************************************
Dim
SMOSQLInstance As New TraceServer
Dim
c As New SqlConnectionInfo(sqlServername, sqlUsername, sqlPassword) c.UseIntegratedSecurity =
False SMOSQLInstance.InitializeAsReader(c, FileName)
While
SMOSQLInstance.Read = True If SMOSQLInstance.GetValue(0) = "SQL:BatchStarting" Then ListView1.Items.Add
(New ListViewItem(New String() {CStr(SMOSQLInstance.GetValue(0)), CStr(SMOSQLInstance.GetValue(1)), CStr(SMOSQLInstance.GetValue(2)), CStr(SMOSQLInstance.GetValue(3)), CStr(SMOSQLInstance.GetValue(4)), CStr(SMOSQLInstance.GetValue(5)), CStr(SMOSQLInstance.GetValue(6)), CStr(SMOSQLInstance.GetValue(7)), CStr(SMOSQLInstance.GetValue(8)), CStr(SMOSQLInstance.GetValue(9)), CStr(SMOSQLInstance.GetValue(10)), CStr(SMOSQLInstance.GetValue(11))})) End If End While*****************************************************But this never happened because the window is forzen when you call the code above. I tried to pause thread and call the same code above from another function and it did work I was able to add the items to ListView but window was still frozen, there were no possible clicks on any window control. Simple what I am trying to do is something like SQL profiler. It will list all activities into ListView and when you click on any item it will give you Sql text in TextBox. But I am not able to do it...
Any guidance would be appreciated
Hi -- I have checked this with a colleague to double check but my previous answer holds. Your UI thread will not update as you are performing synchronous callls. I have included his answer here (thanks Slavik!):
Since SMOSQLInstance.Read is synchronous, it is not advisable to call it from the UI thread (the UI thread would be frozen if SQL Server had not produced any events).
Better solution would be to start (and stop) the trace on the ui thread, but read it on a separate background thread.