05-06-2009 02:44 AM
I have a problem with a callback thread on an RT system. I am working with CVI 8.5 on the pc and the Runtime-engine 9.0 on the RT system.
I am using a client-server-architecture, the client writes data into a 1D network variable, the server is notified via a subscriber connection and releases a callback function. My problem is, this callback function is started in another thread (not the main thread), and is not finished. I have reduced the problem as much as I could, right now the only thing I do in my callback is to dispose of the CNVdata. The problem occurs whenever the callback is released, creating and destroying the subscriber connection without calling the callback does not lead to any problems.
The actual issue about this is that when my program ends, there are still threads left running on the RT system, which may lead to problems later (I have a multi-day-measurement application which crashes always at the same time, so I really need to have this clean).
I'll try to post a code snippet to make sure you get what I do (all in the RT main, for simplicity's sake):
CNVCreateSubscriber (nameData, dataCallback, NULL, NULL, 3000, 0, &dataSubscriber);
while (!RTIsShuttingDown () && !error)
{
ProcessSystemEvents();
Sleep(100);
}
CNVDispose(dataSubscriber);
ProcessSystemEvents();
CloseCVIRTE();
My callback basically looks like this:
void CVICALLBACK dataCallback (void * handle, CNVData data, void * callbackData)
{
CNVDisposeData(data);
}
When I look at my threads at runtime, I see the callback thread when I am inside, but it still is there afterwards. Also, what is CNVDisposeData supposed to do? The "data" variable keeps its value even after disposing. I can see no change at all.
I would really appreciate any comments or ideas, I have been trying to fix this for some days now and really don't know what else I could try!
Solved! Go to Solution.
05-06-2009 05:22 AM
I just added a trace session to see what happens with my threads, for example like this:
TraceUserEvent(2);
error = CNVDisposeData(data);
TraceUserEvent(2);
and I see absolutely nothing happening between the two user event flags. I was just wondering if there should be anything happening.
05-06-2009 10:25 AM
05-07-2009 03:01 AM
Great, with the CNVFinish() the error message has gone, the thread seems to terminate! 🙂 (or at least it doesn't bother me with its state any more 😉 ) Thanks a lot for that hint!
Anyway, about hosting the variables on the PC - this would lead to some problems with multi-client architectures, wouldn't it.
05-07-2009 09:31 AM