Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

CNiGraph context menu in multithreading

I inherited a C++ class from CNiGraph to add a context menu on OnRButtonUp message. This class in named CNiGraphExt.
I placed a graph on a Dialog Box and used a thread to chart data on it. (Plot produces the same problem).
Clicking right button during thread update the application deadlock.
In the zip is attached a sample application.
 
Can you help me with the problem ?
 
thanks
0 Kudos
Message 1 of 10
(6,073 Views)
Can someone help me ??????
 
0 Kudos
Message 2 of 10
(6,006 Views)
No one can help ?
0 Kudos
Message 3 of 10
(5,954 Views)
Tiepolo,

I took a look at your program and I was able to replicate the issue.  Although, the problem occurs intermittently.  I am filing a bug report to the Measurement Studio development team so that they can get a detailed look at the application.  We should be able to figure out what may be occuring.

I will let you know as soon as I hear anything.

Regards,

Tyler T.
0 Kudos
Message 4 of 10
(5,933 Views)

Ooohhhh Ok.

First of all thank you for your reply.

I did a lot of tests but I have not been able to understand how to avoid the problem.

I will wait for news.

Thank you

 

 

0 Kudos
Message 5 of 10
(5,926 Views)

Your best bet at this point is to update the graph from only one thread. You can have the thread generate data, but when it comes time to updating the data on the graph, you can post a message to the main dialog and perform the graph operation from there. Using SendMessage will ensure that the message handler fires in the same thread that created the dialog.

See this document for how to set this up.

You can switch the graph instantiation back to singlethreaded to avoid any additional overhead, since now you will be accessing the graph from a single thread.

Unfortunately MFC does not provide any kind of thread safe queue. I'm not sure how your application is ultimately going to be setup, but if you need a TSQ, I found a good example of one here.

This should get you up and running for now.
Sorry about the incovienience.


Bilal Durrani
NI
0 Kudos
Message 6 of 10
(5,922 Views)
Thanks for your help, but I have just built two applications and now I can't modify their structures. Now I can only wait for a bug fix hoping that National Instruments will make it.
Is there a way to workaround this problem without changing application structure ?
 
Thanks
 
 
0 Kudos
Message 7 of 10
(5,914 Views)
No one with a valid workaround for this bug ?
Use of mutex, critical section or similar ?
Can someone explain me what is causing this bug so I can try to find a possible solution ?
 
thanks
 
0 Kudos
Message 8 of 10
(5,801 Views)
Hello

We're still investigating this bug and do not have another workaround other than the one I mentioned previously. If there is any new information, I will update this thread.

Thanks

Bilal Durrani
NI
0 Kudos
Message 9 of 10
(5,777 Views)
Hi

Take a look at the attached sample. This will let you work around the issue.

The example is not using the inherited graph, its a simplified version. The changes I made were adding locks around accessing the graph object when accessing the object from different threads. You probably already tried this, but the one additional thing that was needed was to pump messages while waiting to get the lock. You can see how to set that up in the example.

I hope this helps

Bilal Durrani
NI
0 Kudos
Message 10 of 10
(5,627 Views)