Asynchronous socket problem w/datagrid

  • Thread starter Thread starter David Troy
  • Start date Start date
D

David Troy

Hi All -- I am new to VB.Net so bear with me.

I have an application where I need to connect to a remote tcp port
synchronously, and then asynchronously wait for a data stream to come
from the connection. As data comes in, I want to parse it and add it
to a DataSet, to be displayed in a Windows Form Datagrid.

To test the idea without fooling with the dataset/datagrid, I wrote my
raw asynchronous response to a TextBox using a Receive/ReceiveCallback
function pair, as per the MS examples. This works fine with no UI
problems.

Now that I have added the DataGrid into the mix, any time I do
anything (click, scroll, select a cell, resize column) to the UI of
the datagrid, it seems like the IO is blocking and the application
freezes until some data gets passed and/or the MS Gods are satisfied.

I'm not sure what's going on. If I turn off the I/O, the datagrid
acts fine. If I don't try to populate the datagrid from my
ReceiveCallback function, but rather with static data on Form_Load,
that works fine too. When I combine the datagrid with the updates
from ReceiveCallback, it gets stuck.

Any help appreciated.

Thanks,
Dave
 
Hi David,

Thanks for posting in this group.
Do you still use asynchronous client to recieve the data when mixing
datagrid?
If you use the asynchronous client, then the ReceiveCallback method will be
called when the data arrived.
I think in the ReceiveCallback, you want to update or add some row data to
the datagrid.
So I think in the ReceiveCallback method, once you got the data, you can
use LoadDataRow or other ways to add to the dataset, then the datagrid will
refresh the new added row data correctly. I think in this logic, your
datagird will not hang.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Do you still use asynchronous client to recieve the data when mixing
datagrid?
If you use the asynchronous client, then the ReceiveCallback method will be
called when the data arrived.
I think in the ReceiveCallback, you want to update or add some row data to
the datagrid.
So I think in the ReceiveCallback method, once you got the data, you can
use LoadDataRow or other ways to add to the dataset, then the datagrid will
refresh the new added row data correctly. I think in this logic, your
datagird will not hang.

What I ended up doing was setting up the asynchronous I/O in a
separate thread, as per an example I found online. This allowed the
UI to respond independently of whatever was going on in the I/O
thread.

Now I am trying to make this asynchronous I/O happen behind a
synchronous webservice front-end, which I am unsure how to do. Any
thoughts?

Cheers,
Dave
 
Back
Top