Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Multi thread in timer

multi thread timer

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 01 August 2013 - 10:48 PM

Hello,
In C#, I have one timer (200 ms) and I have 50 label (or gauge C1) and I should check each value before assign to label or gauge.
Is it right way to use new thread for updating these label or gauge value??

Edited by Roger, 07 August 2013 - 02:31 PM.


#2 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts

Posted 02 August 2013 - 09:37 AM

U cánt have a thread ... to update the label ... try to use Background worker or something.  Once you create a new thread ... it doesn't have access to your winform control anymore.


www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#3 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 02 August 2013 - 05:30 PM

How can I make background worker?



#4 BlackDoom

BlackDoom

    CC Regular

  • Member
  • PipPipPip
  • 45 posts

Posted 07 August 2013 - 02:34 AM

Microsoft has a very good explanation and example for that: http://msdn.microsof...3(v=vs.95).aspx


Edited by BlackDoom, 07 August 2013 - 02:36 AM.


#5 AceInfinity

AceInfinity

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 313 posts

Posted 07 August 2013 - 06:14 PM

What would be wrong with the System.Windows.Forms.Timer? Threaded or not, you'll have to Invoke the UI thread anyways... I don't even see the point in a BackgroundWorker here. The System.Windows.Forms.Timer should be enough for the job; it doesn't block the message queue in between intervals. 50 Labels at 200ms though? That is overkill...

You should only need a single (1) Textbox, and an interval of maybe 400 or 500ms. Past that, it gets to be even more useless, because nobody is going to be able to visually see (or maybe care?) about a super fast interval. Depending on what you're doing you may want to slow that down a bit.

What is this for? - What are you doing exactly?

Edited by AceInfinity, 07 August 2013 - 06:17 PM.

Microsoft MVP (2012) - .NET Programming | ®Crestron DMC-T Certified Programmer
Posted Image





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download