Jump to content


Photo

Windows Form App Loop needed C#


2 replies to this topic

#1 adrlabjack

adrlabjack
  • Members
  • 3 posts

Posted 24 May 2012 - 10:40 PM

Hello, I'm pretty new in Labjack U3 also using C# in Visual Studio 2010. What I basically need is how to implement a basic windows app with a Start/Stop Button where shows the Temperature from AIN0 Temp Sensor in a TextBox window like avary second till I press STOP or close the App. How this never ending loops are created in windows app or which avents can be used to trigger to rescan all inputs/outpus in a LAbjack to design a basic machie controller ? Thanks Adrian

#2 Alexandre

Alexandre
  • Members
  • 5 posts

Posted 30 May 2012 - 06:33 AM

Hello,

I'm pretty new in Labjack U3 also using C# in Visual Studio 2010.

What I basically need is how to implement a basic windows app with a Start/Stop Button where shows the Temperature from AIN0 Temp Sensor in a TextBox window like avary second till I press STOP or close the App.

How this never ending loops are created in windows app or which avents can be used to trigger to rescan all inputs/outpus in a LAbjack to design a basic machie controller ?


Thanks
Adrian


To do this the simple way, with a rough precision, you'll probably want to use the System.Windows.Forms.Timer class.
http://msdn.microsof...orms.timer.aspx

The event raised by the timer (event named Tick in the doc) will be raised in the UI thread, which is good for you if you want to display the information in a WinForm.

Good luck !

#3 LabJack Support

LabJack Support
  • Admin
  • 8279 posts

Posted 30 May 2012 - 02:49 PM

Alexandre is correct, the easiest way to do this is with a Timer object in C#. It can be added to the form in the same way you would add a button or another component. You basically set an interval that it triggers at, and each time it triggers it calls a function you specify. You can set it up so inside that function it reads data from the LabJack. You can then use the buttons to start/stop the timer. That is the easiest way to achieve what you are looking for, as it will let you periodically poll the LabJack without getting stuck in a loop that blocks the UI from responding.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users