BeginInvoke freezes

  • Thread starter leonard.guillaume
  • Start date
L

leonard.guillaume

Hi,

I'm having random problems with BeginInvoke function. I have 2
WebServices (VB.Net), the first one is the main ws and the second is
the backup in case that the primary server crash or goes offline.

My client, which is also in VB.Net tries to connect to the first
webservice and has a timeout of 60 seconds. If it can't connect, it
tries on the backup. The timeout is 60seconds because I'm using a
56kmodem.

The problem is that randomly, the function BeginInvoke, which I use to
call my WS async will freezes. Sometimes, the primary ws will respond
correctly, but the backup will crash. Sometimes they both freezes
BeginInvoke...anyway you see my point. It's very hard to debug
somethings that is random and all the data my client is sending to the
ws are valid. The BeginInvoke freezing gets my client GUI to freeze.

Any hints ?

Thanks :)

Guillaume L.
 
L

leonard.guillaume

Here's some code to help :

oWS = New WSTelChoix.SessionWS
bWebServiceCantConnect = False
oWS.Url = SoapCommunication.GetURLWSTelchoix
oWS.SoapAuthorizationValue = SoapCommunication.Authorization

ar = oWS.BeginGetSession(oEncrypt.Encrypt(txtPhoneNumber.Text,
EncryptKey.Key, EncryptKey.IV), oEncrypt.Encrypt(txtPassword.Text,
EncryptKey.Key, EncryptKey.IV),
moUserSettings.IDISPAccount(iMainUtilization),
oEncrypt.Encrypt(oRasDialer.InternetAddress, EncryptKey.Key,
EncryptKey.IV), oRasDialer.ConnectSpeed, oEncrypt.Encrypt((New
LocalInfo).ToStringInfo(False), EncryptKey.Key, EncryptKey.IV),
Nothing, Nothing)

iCount = 0

While Not ar.IsCompleted AndAlso iCount < conWebServicesTimeout
System.Threading.Thread.Sleep(frmMain.conWSDownloadInterval)
iCount += conWSDownloadInterval
Application.DoEvents()
End While

If ar.IsCompleted Then
oSessions = oWS.EndGetSession(ar)
Else
If Not iCount = conWebServicesTimeout Then
oWcar = CType(ar, WebClientAsyncResult)
oWcar.Abort()
End If

bWebServiceCantConnect = True
Throw New Exception
End If

The variable "i" is the variable of a For and will decides w
 
L

leonard.guillaume

Here's some code to help :

oWS = New WSTelChoix.SessionWS
bWebServiceCantConnect = False
oWS.Url = SoapCommunication.GetURLWSTelchoix
oWS.SoapAuthorizationValue = SoapCommunication.Authorization

ar = oWS.BeginGetSession(oEncrypt.Encrypt(txtPhoneNumber.Text,
EncryptKey.Key, EncryptKey.IV), oEncrypt.Encrypt(txtPassword.Text,
EncryptKey.Key, EncryptKey.IV),
moUserSettings.IDISPAccount(iMainUtilization),
oEncrypt.Encrypt(oRasDialer.InternetAddress, EncryptKey.Key,
EncryptKey.IV), oRasDialer.ConnectSpeed, oEncrypt.Encrypt((New
LocalInfo).ToStringInfo(False), EncryptKey.Key, EncryptKey.IV),
Nothing, Nothing)

iCount = 0

While Not ar.IsCompleted AndAlso iCount < conWebServicesTimeout
System.Threading.Thread.Sleep(frmMain.conWSDownloadInterval)
iCount += conWSDownloadInterval
Application.DoEvents()
End While

If ar.IsCompleted Then
oSessions = oWS.EndGetSession(ar)
Else
If Not iCount = conWebServicesTimeout Then
oWcar = CType(ar, WebClientAsyncResult)
oWcar.Abort()
End If

bWebServiceCantConnect = True
Throw New Exception
End If
 
K

Kevin English

This is most likely a locking issue. If the invoking thread owns a lock
that the invoked thread requests, you will hang.
 
W

William Stacey [MVP]

I assume by your description that you call BeginInvoke on the UI thread. Is
there a reason your doing this? As shown this will "freeze" your UI for any
long running operation like waiting for a network reply so no other events
are processed on UI Q until return or DoEvents(). I would just use a worker
thread and only post back results to the UI after success/failure/progress.

--
William Stacey [MVP]

| Hi,
|
| I'm having random problems with BeginInvoke function. I have 2
| WebServices (VB.Net), the first one is the main ws and the second is
| the backup in case that the primary server crash or goes offline.
|
| My client, which is also in VB.Net tries to connect to the first
| webservice and has a timeout of 60 seconds. If it can't connect, it
| tries on the backup. The timeout is 60seconds because I'm using a
| 56kmodem.
|
| The problem is that randomly, the function BeginInvoke, which I use to
| call my WS async will freezes. Sometimes, the primary ws will respond
| correctly, but the backup will crash. Sometimes they both freezes
| BeginInvoke...anyway you see my point. It's very hard to debug
| somethings that is random and all the data my client is sending to the
| ws are valid. The BeginInvoke freezing gets my client GUI to freeze.
|
| Any hints ?
|
| Thanks :)
|
| Guillaume L.
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top