Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

I'd like to speed up UI response time in my application.

I have a program that aquires data at 1 Hz and displays it to the screen and writes it to a file.  The entire process isn't that long, but when I move the window or drag another window over my window the update rate is slow.  Using traditional windows programs, the update rate is almost instantaneous even if the application is busy. 
 
What is the best way to use threading to speed this up?
 
Make the whole process for reading and writing data a thread?
 
Thanks.
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 1 of 10
(5,519 Views)
search for this thread


vb.net delegates in Measurement Studio?

it might help you

my acquisition thread is separate from my UI now
Philip Newman
General Dynamics
Electric Boat
Message 2 of 10
(5,508 Views)
I have a program that reads and stores [analog input voltage] data at 1 Hz while also controlling an engine at 1 Hz and then starting closed loop control at 30 Hz.

I currently have the reading/storing calls in one timer and the ramp time control in another timer. After steady state is reached, a third timer starts at 30 Hz.

I want these tasks to be done in threads so the form will respond to events sooner. Right now it seems as though it reponds at the same frequency: 1 Hz, even though that code doesn't generally run more than 150 ms.

I tried:

VB:
Dim ReadThread As New Thread(AddressOf ReadCode)
Dim ProcessThread As New Thread(AddressOf ProcessCode)

ReadTimer.Tick
ProcessThread.Start()
End Sub

ControlTimer.Tick
ProcessRead.Start()
End Sub



but it is saying that I can't start the thread because it is running. What can I do to resolve this problem? Thanks.
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 3 of 10
(5,501 Views)
Could you post a  screen shot of the error message you are getting?  I'm not sure I completely understand what you are looking for.  How are you collecting the data?  Serially?  What version of Measurement Studio do you have?  Are you saying that you want it to run faster than 150ms?  Any more info would definitely help. Thanks!!!
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 10
(5,466 Views)
The error says: Can't start thread because it is already running.
 
I have no problem executing threads that run only once, but when I put them in a timer where they execute at 1 Hz they don't work anymore.  Is it that you have to kill the thread and the end of its code before you can start again or what?
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 5 of 10
(5,447 Views)
If you are trying to start the same thread over and over it will throw that error.  You can start the thread before your loop.  Then you just have one thread running.  But I assume you wanted to have a different thread for each loop?!  In this case you would have to kill the thread before starting the new one.
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 6 of 10
(5,443 Views)

This is what I want to do:

[vb]

Dim ReadThread As New Thread(AddressOf ReadCode)
Dim CycleThread As New Thread(AddressOf ProcessCode)

' This is the timer than reads data at 10 Hz
Sub ReadTimer.Tick
ReadThread.Start()
End Sub

' This is the timer that makes control decisions at 1 Hz

Sub ControlTimer.Tick
CycleThread.Start()
End Sub

[/vb]

On the second iteration the thread throws an error.  Do I need to kill it at the end of code execution?

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 7 of 10
(5,439 Views)
Yes you need to kill it at the end of each iteration.  That is if you want to start a new thread each time through the loop with the same name.
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 8 of 10
(5,416 Views)
By the command CycleThread.Stop or what?
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 9 of 10
(5,411 Views)
Yes you can kill it by calling [threadname].Stop().  There is more information on multithreading on the Microsoft Website if you are using VB.NET.
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 10 of 10
(5,404 Views)