locked
Multi-Threading, TPL, etc. RRS feed

  • Question

  • Hello!

    I have just written an app in VB 2010 with .NET 4.0 that contacts our field loggers to collect data via modem or IP.  Originally it was written without threading, but now the requirements have changed and I need to collect data simultaneously from 4-6 sites at a time.  I have never used threading, TPL, etc.  Can anybody tell me where to begin so that I can concurrently run multiple collections?

    Thanks!
    - Wendy

    Wednesday, May 4, 2011 5:03 PM

Answers

  • You may not need a backround worker.

    Presumably these modems would communicate over serial ports (Com1, Com2, Com 3, ..., Com N). Each serial port object will fire data-received events on their own threads. You wouldn't need to create any threads, but would have to consider the implications of synchronizing the data from these threads and your main thread.


    Stephen J Whiteley
    • Proposed as answer by Mike Feng Friday, May 6, 2011 7:59 AM
    • Marked as answer by Mike Feng Friday, May 13, 2011 7:11 AM
    Wednesday, May 4, 2011 7:25 PM

All replies

  • Hello mtnrnrchic,

    Welcome to the forums.

    and you can Begin Here :-)


    Thanks

    Social lounge for MSDN forum users :-)
    Living on Earth may be expensive, but did you know that it includes a free trip around the sun? Isn't that worth it?
    Wednesday, May 4, 2011 6:35 PM
  • Thanks Omie!  I started my search looking at the BackgroundWorker but was quickly turned away as it seemed to get a bad rap.  Is there anything wrong with using it?  I try not to bother with shortcuts, etc. that bring out the newbie in my code!?!?  Sounds like I may need to give it a second look?!?!
    Wednesday, May 4, 2011 6:45 PM
  • There's nothing wrong with the background worker at all. It encapsulates several common elements so you don't have to code for it: Creates a thread for you, allows a 'progress' method to be called, eliminates any cross-threading issues when reporting progress to a UI thread.

    If you must have threading, after trying it without threading, I'd start with a single thread - a single backgroundworker object - and monitor the performance. Multiple threads rarely bring a (huge) performance increase, but that depends on what you are trying to do.


    Stephen J Whiteley
    Wednesday, May 4, 2011 6:50 PM
  • I am hoping to make several concurrent modem calls to collect data.  Each phone call takes from 1 to 3 minutes and the data collected is time sensitive.  Sooo, I'm hoping to get some hardware with 6 modems or so and be able to make multiple calls at once.  Should that be possible with VB?
    Wednesday, May 4, 2011 7:09 PM
  • You may not need a backround worker.

    Presumably these modems would communicate over serial ports (Com1, Com2, Com 3, ..., Com N). Each serial port object will fire data-received events on their own threads. You wouldn't need to create any threads, but would have to consider the implications of synchronizing the data from these threads and your main thread.


    Stephen J Whiteley
    • Proposed as answer by Mike Feng Friday, May 6, 2011 7:59 AM
    • Marked as answer by Mike Feng Friday, May 13, 2011 7:11 AM
    Wednesday, May 4, 2011 7:25 PM
  • Hi Wendy,

     

    Thanks for posting in the MSDN Forum.

     

    Any update? I have marked Stephen's reply as answer, if you think it provides no help, please unmark it, and  feel free to let me know your any concerns.

     

    Thank you for your understanding and support.

     

    Best Regards,
    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, May 13, 2011 7:11 AM