Jump to content
Ian Branch

Preventing and allowing things to happen in a Thread???

Recommended Posts

Hi Team,

Books have been written about what I don't know about threading... 😉

I have experimented with Anonympus threads.

Is it possible to prevent the App doing anything except being moved, and parhas resized, while a thread is running?

Regards & TIA,

Ian

Share this post


Link to post

Anything is possible, yes. You are going to have to be more specific about your particular situation.

 

It sounds like you just want to disable your UI while the thread is running. But then why use a thread at all?

Share this post


Link to post
35 minutes ago, Remy Lebeau said:

But then why use a thread at all?

Because I still want them to be able to move and resize the App/Form while the thread is running.

If I do it in the main thread the form becomes unresponsive.

Edited by Ian Branch

Share this post


Link to post

The challenge is often identifying all the ways that an app can activate stuff while the thread is executing.

You could f.x. have a busy flag (or set of flags) you set when you start the thread, and clear on completion, so that when a user opens a menu you can use the flag(s) to disable menu and buttons items that can't be used while the thread is running.

 

Share this post


Link to post
5 hours ago, Ian Branch said:

Hi Team,

Books have been written about what I don't know about threading... 😉

I have experimented with Anonympus threads.

Is it possible to prevent the App doing anything except being moved, and parhas resized, while a thread is running?

Regards & TIA,

Ian

Put all controls on the form on a client-aligned panel and then simply disable the panel while the background thread is active. Also use a handler for the OnCloseQuery event to prevent closing of the app while the thread is running. If you have a main menu bar tie all menu items to actions and disable the actionlist while the thread is running. Just don't forget to enable all the stuff again when the thread is done. :classic_cool:

  • Like 4

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×