Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi everyone, i'm using C++ managed 2010 for designing a GUI in a form.h file. The GUI acts as a master querying data streaming from slave card.

Pressing a button a function (in the ApplicationIO.cpp file) is called in which 2 threads are created by using API win32 (CREATETHREAD(...)): the former is for handling data streaming, and the latter is for data parsing and data monitoring on real time grpah on the GUI.

The project has two different behaviour: if it starts in debugging mode it is able to update GUI controls as textbox (using invoke) and graph during data straming, contrariwise when it starts without debugging no data appears in the textbox, and data are shown very slowly on the chart.

how does it is possible to run project starting without debuging like starting debugging mode?
is the problem about project settings, or is "begininvoke" a solution to use instead invoke?
Posted

Are the two different behaviors the way you want it to work, or are you asking why it doesn't work the same when running with or without the debugger? It should work the same regardless of whether or not the debugger is attached to the process.

Regarding the Invoke question, there are a few variations on what you want to do (updating the UI from a non-UI thread). All of these ways are valid and should produce the same results.
 
Share this answer
 
Comments
Pikozzo 19-Mar-11 13:43pm    
i would like a solution that works running wihtout debugger. Unfortunately for the moment only solution starting with debugging (F5 key) is working.

I try to update GUI controls form another thread that create the controls while a second thread is resposable to receive data streaming caming from a card.

I don't know if yhe problem of different behaviour is due to the use of Invoke() (Perhaps BeginInvoke() doesn't throttles) or some special solution settings.
Sergey Alexandrovich Kryukov 20-Mar-11 22:12pm    
What you say is correct, my 5, but I smell race condition (could be at least one more reason though), see my Answer.
--SA
Different behavior in Debug and Release configuration in threaded code is a good sign of race condition, see http://en.wikipedia.org/wiki/Race_condition[^]. I prefer more descriptive form of such phenomena: "incorrect dependency on the order of execution". Please checkup the logic of your threads communications and use of shared resources.

Less likely reason is automatic filling of non-assigned members in C++ objects which can be more deterministic in Debug configuration.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900