Click here to Skip to main content
15,908,775 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionHow to stop a simulation while running Pin
KlaasVersteeg21-Jun-10 22:27
KlaasVersteeg21-Jun-10 22:27 
AnswerRe: How to stop a simulation while running Pin
Luc Pattyn22-Jun-10 1:21
sitebuilderLuc Pattyn22-Jun-10 1:21 
GeneralRe: How to stop a simulation while running Pin
KlaasVersteeg22-Jun-10 5:31
KlaasVersteeg22-Jun-10 5:31 
GeneralRe: How to stop a simulation while running Pin
Luc Pattyn22-Jun-10 6:07
sitebuilderLuc Pattyn22-Jun-10 6:07 
GeneralRe: How to stop a simulation while running Pin
KlaasVersteeg22-Jun-10 20:38
KlaasVersteeg22-Jun-10 20:38 
AnswerRe: How to stop a simulation while running Pin
Luc Pattyn23-Jun-10 2:22
sitebuilderLuc Pattyn23-Jun-10 2:22 
GeneralRe: How to stop a simulation while running Pin
KlaasVersteeg23-Jun-10 2:42
KlaasVersteeg23-Jun-10 2:42 
AnswerRe: How to stop a simulation while running Pin
Luc Pattyn23-Jun-10 3:14
sitebuilderLuc Pattyn23-Jun-10 3:14 
Hi,

that code is not really OK. I do not know what is the exact cause of your symptoms, however I'll offer some comments that should bring you closer to success:

1.
I would defer all initialization of the simulator till the start button is pressed. You don't need a BGW if no simulation is ordered.

2.
I would then also disable the start button (and enable the stop button) for as long as the simulator is running.

3.
a BGW needs more initialization; have a look at one of the examples, e.g. here[^]. You probably want to include (this is C#, change syntax as required):
bw.WorkerSupportsCancellation = true;
bw.WorkerReportsProgress = true;
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);


4.
You should provide a RunWorkerCompleted handler; that is where the results become available, the exceptions of DoWork are available (through e->Error), and the start button could be re-enabled (and the stop button disabled again).

5.
You could use the built-in BGW cancellation mechanism, although having your own could probably be equally good.

6.
FYI: other threads are not allowed to touch GUI parts, however both the ProgressChanged and RunWorkerCompleted handlers run on the main thread (assuming you created the BGW on the main thread), and so are allowed to modify the GUI. Your model might take advantage of that.

7.
a BGW uses a ThreadPool thread, i.e. its thread gets recycled automatically, you don't need to worry about that. Use a new BGW each time! Maybe (your symptom description was a bit cryptic here) together with (1) above, that is what caused your discomfort in compiling/running/debugging.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.


GeneralRe: How to stop a simulation while running [modified] Pin
KlaasVersteeg23-Jun-10 21:08
KlaasVersteeg23-Jun-10 21:08 
GeneralRe: How to stop a simulation while running Pin
Luc Pattyn24-Jun-10 2:48
sitebuilderLuc Pattyn24-Jun-10 2:48 
GeneralRe: How to stop a simulation while running Pin
KlaasVersteeg24-Jun-10 3:04
KlaasVersteeg24-Jun-10 3:04 
GeneralRe: How to stop a simulation while running Pin
Luc Pattyn24-Jun-10 3:38
sitebuilderLuc Pattyn24-Jun-10 3:38 
GeneralRe: How to stop a simulation while running Pin
KlaasVersteeg24-Jun-10 3:49
KlaasVersteeg24-Jun-10 3:49 
Questionproblem with BOOST threads with mixed mode C++/CLI and Visual Studio 2010 [modified] Pin
T210221-Jun-10 18:38
T210221-Jun-10 18:38 
AnswerRe: problem with BOOST threads with mixed mode C++/CLI and Visual Studio 2010 Pin
Paul Michalik20-Aug-10 23:14
Paul Michalik20-Aug-10 23:14 
GeneralRe: problem with BOOST threads with mixed mode C++/CLI and Visual Studio 2010 Pin
T210220-Aug-10 23:22
T210220-Aug-10 23:22 
GeneralRe: problem with BOOST threads with mixed mode C++/CLI and Visual Studio 2010 [modified] Pin
Paul Michalik21-Aug-10 23:40
Paul Michalik21-Aug-10 23:40 
GeneralRe: problem with BOOST threads with mixed mode C++/CLI and Visual Studio 2010 Pin
T210222-Aug-10 1:27
T210222-Aug-10 1:27 
GeneralRe: problem with BOOST threads with mixed mode C++/CLI and Visual Studio 2010 Pin
Paul Michalik22-Aug-10 21:46
Paul Michalik22-Aug-10 21:46 
GeneralRe: problem with BOOST threads with mixed mode C++/CLI and Visual Studio 2010 Pin
T210223-Aug-10 3:38
T210223-Aug-10 3:38 
QuestionUnraveling the Mysteries of Writing a Winsock 2 Layered Service Provider Pin
Pascal Ganaye21-Jun-10 12:16
Pascal Ganaye21-Jun-10 12:16 
AnswerRe: Unraveling the Mysteries of Writing a Winsock 2 Layered Service Provider Pin
Pascal Ganaye22-Jun-10 14:26
Pascal Ganaye22-Jun-10 14:26 
GeneralRe: Unraveling the Mysteries of Writing a Winsock 2 Layered Service Provider Pin
Richard Andrew x6422-Jun-10 14:32
professionalRichard Andrew x6422-Jun-10 14:32 
QuestionAssembly info not showing up in explorer in managed DLL Pin
alleyes16-Jun-10 9:01
professionalalleyes16-Jun-10 9:01 
AnswerRe: Assembly info not showing up in explorer in managed DLL Pin
Nish Nishant19-Jun-10 7:25
sitebuilderNish Nishant19-Jun-10 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.