Search:
Namespaces
Discussions
.NET v1.1
Feedback
ASYNC SOCKET and FREEZE
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.compactframework
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
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
Reply to this message...
Alex Yakhnin [MVP] (VIP)
The async. sockets are executed on the separate thread.
This is why the update of the UI thread is failing. You
must use
Control
.Invoke if you don't want to have any
problems.
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnnetcomp/html/netcfmultithreadedapp.asp
--
Alex Yakhnin, .NET CF MVP
http://www.intelliprog.com
blog:
http://blog.opennetcf.org/ayakhnin
[Original message clipped]
Reply to this message...
System.EventHandler
System.IAsyncResult
System.Text.Encoding
System.Threading.Thread
System.Web.UI.Control
System.Windows.Forms.Application
System.Windows.Forms.MenuItem
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com