G
Guest
I have been working on a problem for over two months now, but I can't seem to
get past it.
I have a custom class that makes an remoting call to a web server to
retrieve data. I don't want the UI to "hang" while this process is occuring,
so I have the custom class perform the remoting call on a seperate thread.
When the thread has retrieved all of the data is uses the RaiseEvent keyword.
The event is handled by the UI and is instructed to show a new form (not a
messagebox). The new form flashes up and then disappears almost immediately
(when I actually want it to stick around for a few seconds). However, if I
call the remoting method directly, when the event is raised it is handled as
expected by the UI. I know that it is probably because the event that is
being raised is actually raised on the new thread, but I'm at a loss how to
get past this.
Here is an example of the code:
Public Class RemotingCallObject
Private _Thrd as System.Threading.Thread
Public Event RemoteCallComplete(ByVal sender as Object, ByVal e as
EventArgs)
public sub new()
_Thrd = New System.Threading.Thread(AddressOf GetWebData)
end sub
public sub AsyncCall
_Thrd.Start()
end sub
public sub GetWebData()
' contact the web server and get the new data
RaiseEvent RemoteCallComplete(Me, Nothing)
End Sub
End Class
This is an excerpt from the winform
Public Class MainForm
' Designer Code
Private WithEvents _RC as New RemotingCallObject
Public Sub OnCallComplete(ByVal sender as object, e as EventArgs)
Handles _RC.RemoteCallComplete
Dim PF as new PopupForm
PF.Show()
End Sub
Public Sub Button1_Click(ByVal sender as Object, ByVal e as EventArgs)
Handles Button1.Click
' Calling this method creates my odd behavior, but does not make
the
' UI unresponsive.
_RC.AsyncCall
' Calling this method works as expected, but makes the UI "hang"
_RC.GetWebData
End Sub
End Class
Thanks for any help.
get past it.
I have a custom class that makes an remoting call to a web server to
retrieve data. I don't want the UI to "hang" while this process is occuring,
so I have the custom class perform the remoting call on a seperate thread.
When the thread has retrieved all of the data is uses the RaiseEvent keyword.
The event is handled by the UI and is instructed to show a new form (not a
messagebox). The new form flashes up and then disappears almost immediately
(when I actually want it to stick around for a few seconds). However, if I
call the remoting method directly, when the event is raised it is handled as
expected by the UI. I know that it is probably because the event that is
being raised is actually raised on the new thread, but I'm at a loss how to
get past this.
Here is an example of the code:
Public Class RemotingCallObject
Private _Thrd as System.Threading.Thread
Public Event RemoteCallComplete(ByVal sender as Object, ByVal e as
EventArgs)
public sub new()
_Thrd = New System.Threading.Thread(AddressOf GetWebData)
end sub
public sub AsyncCall
_Thrd.Start()
end sub
public sub GetWebData()
' contact the web server and get the new data
RaiseEvent RemoteCallComplete(Me, Nothing)
End Sub
End Class
This is an excerpt from the winform
Public Class MainForm
' Designer Code
Private WithEvents _RC as New RemotingCallObject
Public Sub OnCallComplete(ByVal sender as object, e as EventArgs)
Handles _RC.RemoteCallComplete
Dim PF as new PopupForm
PF.Show()
End Sub
Public Sub Button1_Click(ByVal sender as Object, ByVal e as EventArgs)
Handles Button1.Click
' Calling this method creates my odd behavior, but does not make
the
' UI unresponsive.
_RC.AsyncCall
' Calling this method works as expected, but makes the UI "hang"
_RC.GetWebData
End Sub
End Class
Thanks for any help.