TRACE FREEZES CURRENT CONTEXT

Hello,
I have troubles when usingSMO 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 useThread.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)
[408 byte] By [NebimYazilim] at [2008-2-10]
# 1

Hi -- I am not exactly sure what you are trying to do. Could you post a code sample to illustrate what you are trying to do? Note that if you are processing data in a close loop the UI will not update, as you need to release control back to the event handler, so that it can update the UI.

Also see this article:
http://msdn.microsoft.com/netframework/archive/default.aspx?pull=/library/en-us/dnvs05/html/threadinginvb2005.asp

MichielWories at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 2
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

NebimYazilim at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 3
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.

MichielWories at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...

SQL Server

Site Classified