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
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