Background information - I have a main form (fBoard) that creates & starts a listener thread (thTcpListener) which is responsible for receiving incoming network data from the server.
So, my question is pretty much two-fold:
- How do I pass the data that was recieved from the Thread (thTcpListener) to the main form (fBoard)?
- How do I then notify the main form (fBoard) that data is ready and waiting to be used?
Specifically - the data recieved in a custom object (objCustom) and fBoard has a "private ObjCustom objCustom" member that needs to be updated with this incoming data when it arrives.
The main form (fBoard) will create & start the listener thread (thTcpListener) and wait for it to recieve the objCustom.
When the object is recieved the thread should "somehow" pass it to fBoard and notify it that data has arrived, fBoard will then process the object and again wait for the next objCustom to arrive, this will happen continously (as the application is running)...
As for the notification, this is going to be tricky ... The user is interacting with fBoard so I can't just Wait on the thread to return data (like using a ManualResetEvent) - I was thinking of simply using a DELEGATE function to solve my problem...
So when the thread recieves the data call the Delegate Function on the main board (fBoard) and it can do all the work for me (including possibly passing the data?)
Other then using somekind of a delegate I have NO CLUE how to "pass the object/data" from the thread to the main form (fBoard)... This is where I really need help...
I was thinking I could use something like a QUEUE that I would share (using a ReaderWriterLock to make it threadsafe) or something along those lines - but is there something better? or something intended for this situation...
Anyways - I think I can solve this using some trial-and-error (via delegates) but I want to ensure I am using a conventional and secure method....
Any ideas, hints, and help would be greatly appreciated, thanks
So, my question is pretty much two-fold:
- How do I pass the data that was recieved from the Thread (thTcpListener) to the main form (fBoard)?
- How do I then notify the main form (fBoard) that data is ready and waiting to be used?
Specifically - the data recieved in a custom object (objCustom) and fBoard has a "private ObjCustom objCustom" member that needs to be updated with this incoming data when it arrives.
The main form (fBoard) will create & start the listener thread (thTcpListener) and wait for it to recieve the objCustom.
When the object is recieved the thread should "somehow" pass it to fBoard and notify it that data has arrived, fBoard will then process the object and again wait for the next objCustom to arrive, this will happen continously (as the application is running)...
As for the notification, this is going to be tricky ... The user is interacting with fBoard so I can't just Wait on the thread to return data (like using a ManualResetEvent) - I was thinking of simply using a DELEGATE function to solve my problem...
So when the thread recieves the data call the Delegate Function on the main board (fBoard) and it can do all the work for me (including possibly passing the data?)
Other then using somekind of a delegate I have NO CLUE how to "pass the object/data" from the thread to the main form (fBoard)... This is where I really need help...
I was thinking I could use something like a QUEUE that I would share (using a ReaderWriterLock to make it threadsafe) or something along those lines - but is there something better? or something intended for this situation...
Anyways - I think I can solve this using some trial-and-error (via delegates) but I want to ensure I am using a conventional and secure method....
Any ideas, hints, and help would be greatly appreciated, thanks