Hi;
I have two applications A and B
*** Application B listens on a network stream with a callback function:
-------------------------------------------
Public Sub WaitForData()
If Callback Is Nothing Then
Callback = New AsyncCallback(A ddressOf OnDataReceived)
End If
If Not bMyRun Then
Me.objMyNetwork Stream.Close()
Else
Me.m_asynResult = objMySocket.Beg inReceive(objMy Bytes, 0,
objMyBytes.Leng th, SocketFlags.Non e, Callback, Nothing)
End If
End Sub
----------------------------------------------------------------
Public Sub OnDataReceived( ByVal asyn As IAsyncResult)
Dim iRx As Integer = 0
Dim sLCompleteMessa ge As String
If Me.objMySocket. Connected Then
iRx = Me.objMySocket. EndReceive(asyn )
End If
If iRx > 0 Then
Dim numberOfBytesRe ad As Integer = 0
sLCompleteMessa ge =
Encoding.ASCII. GetString(objMy Bytes).Substrin g(0, iRx)
RaiseEvent OnDataReceivedE vent(sLComplete Message)
Me.WaitForData( )
End If
End Sub
-----------------------------------------
The OnDataReceived function is called when... data receives on the
networkstream. As you can see an event is raised (RaiseEvent
OnDataReceivedE vent).
Application A receives this event and does a refresh of the listview.
Now my question is the following:
The listview in application A can be refreshed by pressing F5 or by
receiving the event raised by Application B.
When the listview is being refresh manually (F5-press) the refresh is very
fast.
When the listview is being refresh automatically (by receiving event of
application B) the refresh goes very slow and the screen is being repainted
very slowly.
Is there something wrong with the OnDataReceived Sub ? Is this a threading
problem? Anyone any idea why the refresh slows down when it is triggered
externally by application B ?
Hope someone can help me out.
Regards
MVK