user264431
user264431

Reputation:

Reacting to User Interface events in Visual Studio during a processing loop

I'm developing in Visual Studio in C++, all managed code. I have a tight processing loop that, theoretically, can run for up to around 30 seconds. During that time, I want the UI to be reactive to any user activity, such as pressing a "Stop" button, or clicking a scroll bar.

I know the technique is to peek at the UI queue (in a non-blocking way) and then, if something's there, react to it, but this is frustrating, because I cracked this problem before, but it was about 4 years ago and I no longer have the code base to refer to.

Anybody out there can help me?

Thanks in advance

Upvotes: 1

Views: 54

Answers (1)

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120997

You need to do the processing in a background thread. Check the BackgroundWorker class for example.

Upvotes: 2

Related Questions