Answer the question
In order to leave comments, you need to log in
Calling a Windows Forms function outside of the Forms class?
There is a need to display text on the form from the program flow, located in another class, but as far as I know, the form functions are available only from the form class, how to get around this, please tell me.
Answer the question
In order to leave comments, you need to log in
After all, this is your class inherited from Form, in it you can write any of your methods and set them as public.
It remains only to pass to the class you are interested in a pointer to an instance of the form class.
Here your problem is described in detail.
In short: to call a form method from another thread, you need to call it through the Invoke mechanism. Here's an example from there:
public static void InvokeIfRequired(this ISynchronizeInvoke obj,
MethodInvoker action)
{
if (obj.InvokeRequired) {
var args = new object[0];
obj.Invoke(action, args);
} else {
action();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question