Cancel threads associated with unbound objects

I am working on a form in this form when the user clicks the create new stream button, which created a new form and did a certain job and showed the result. See the following code. I made a main class in my project that stores links of each type of object.

Program.someFormReference

When the user clicks the button, a new thread is created and Program.someFormReference = new CreatedForm (). Now, what happens if the user clicks the button more than once. We have several objects in memory with threads running on them. But I had a link to only one thread. One way to avoid this situation is to disable the button until the thread completes its execution. Another solution may be to avoid this uncontrolled chain of threads.

+3
source share
1 answer

First you need to solve the following question:

Do you want one or more of these threads to be active?

It seems you have not decided on this issue, so first select it.

, : , , :

  • .
  • ,

, , . . :

Application.Run(someform);

. someform.Invoke, , , .

, : , , , .. ..

0

All Articles