[HELP] ASYNC SOCKET and FREEZE

B

brandon kim

i have implemented socket(async) program with pocketpc 2003
and vb.net.

After PDA received a message from server, program show
this message on MenuItem in Form. but when message is
written on MenuItem, program freeze without any error msg
i really don't know why.

i spent almost a week and get no result.

please help!
following is brief of my code

thanks in advance...

+++++clsSocket.readFromServer++++++++++++++++++++++++++
+ receive message and raise event to handle message
+ in mainForm
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

Public Sub readFromServer(ByVal ar As IAsyncResult)
Dim BytesRead As Integer
Dim strMessage As String
Dim intStart As Integer
Dim intEnd As Integer

If bSocketEnd Then
Exit Sub
End If

Try
BytesRead = pdaClient.GetStream.EndRead(ar)
pdaClient.GetStream.Flush()


If BytesRead < 1 Then

msgbox("serverend")
Exit Sub
End If

strMessage = Encoding.ASCII.GetString(readBuffer, 0,
BytesRead)

RaiseEvent recvMsgEvent(strMessage)

'Start a new asynchronous read into readBuffer
pdaClient.GetStream.BeginRead(readBuffer, 0, _
READ_BUFFER_SIZE, AddressOf readFromServer,
Nothing)

Catch e As Exception

msgbox(e.ToString)

End Try
End Sub


+++++mainForm.processMsg+++++++++++++++++++++++++++++++
+ receive message EventHandler
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

Public Sub processMsg(ByVal strMessage As String)
Dim strTemp As String = "what's going on...."

clsCommon.insertListView(lvwResult, strMessage)

'*****FREEZE HERE*************************
MenuItem1.Text = strTemp
'*****************************************

Thread.CurrentThread.Sleep(50)
Application.DoEvents()

txtResult.Text = strMessage
End Sub
 

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