.net - timeout for method on UI thread -


I have a problem that I am instenciating an item on the UI (WinForms) This object creation probably takes a lot of time, and I will have to give some time to the method (because it is blocking my app).

I have problems: 1. The object should be made on the UI thread 2. The object is a foreign object, and I do not have any source access, so I can not modify it.

Then I would have a question, if there is a constructive idea, if it is possible to make any argument which stops the method to execute if a time limit is reached?

tia martin

Here's a bad solution to monitor the UI formula Use the worker thread on the timer. If the timer ends before the object is created, then the worker thread is the call abort on the UI thread. This will increase a threadboot exposure in the UI thread that you have to capture. The reason why this is bad is because you can hang or crash your program, when an exception is raised, then depends on the state of the astral timing and the race.

A "safe" method will call worker call interrupt - This will increase a thread-based expansion in the UI thread, but when it is WaitSleepJoin situation - if the thread never sleeps then it will not be in the middle, but at least it will not either manage or corrupt.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -