• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

Updating of Winform UI every second

Hi, i have a UI which displays values (Around 40) and i have to update all the 40 values every second as there are chances..the values will be altered at any time. But creating a loop and updating the UI every sec..i figured out it will make the UI super unresponsive..or the UI won't even show up. I have tried using timers for such an app in vb6 and the result was an unresponsive UI. Are there any way i can create multiple threads to update my UI (i.e getting the threads to UI so that load can be shared instead of getting the main app thread to do it all) Some simple code sample would be best or links to resources and case studies regarding this. Thanks
0
jaxrpc
Asked:
jaxrpc
2 Solutions
 
AlexFMCommented:
Updating UI evry second by timer doesn't look like complicated task. I think that this is what you should do.
Notice that worker thread cannot update UI directly, it must call UI function using Invoke or BeginInvoke function. Function which updates UI in any case runs in main application thread.
You don't say anything about source of information. Worker thread can do some calculations, read data from some device or socket, but UI is always updated from amin thread.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Encapsulate your Thread in a Class that raises a custom Event.  When the main form receives the Event, use a Delegate and the Invoke() method to marshal the call from the thread onto your main UI thread.

Here are some examples:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21741689.html
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21729609.html
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21702866.html
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now