Multithreading

  • Thread starter Thread starter victor
  • Start date Start date
V

victor

Hello,

When in my main WinForm thread I do a 'new' instance to a method in
another class, in the same project, does this create a new thread or
not?
Expl:
public class Form1
{
private AnotherClass myInterface;
.....
myInterface = new AnotherClass(this);
....
}
And what if the other class resides in another sub-project?

Thanks, victor.
 
victor said:
Hello,

When in my main WinForm thread I do a 'new' instance to a method in
another class, in the same project, does this create a new thread or
not?
Expl:
public class Form1
{
private AnotherClass myInterface;
....
myInterface = new AnotherClass(this);
...
}
And what if the other class resides in another sub-project?

The instance is created on the same thread as your application thread.
 
Hello,

When in my main WinForm thread I do a 'new' instance to a method in
another class, in the same project, does this create a new thread or
not?
Expl:
public class Form1
{
private AnotherClass myInterface;
....
myInterface = new AnotherClass(this);
...}

And what if the other class resides in another sub-project?

Thanks, victor.

It will always be created in the same thread. You'll only create
other threads if you explicitly use System.Threading, or the WinForms
BackgroundWorker component.
 
Hello,

When in my main WinForm thread I do a 'new' instance to a method in
another class, in the same project, does this create a new thread or
not?
Expl:
public class Form1
{
private AnotherClass myInterface;
....
myInterface = new AnotherClass(this);
...}

And what if the other class resides in another sub-project?

Thanks, victor.

It does not create a new thread. A method, or constructor in your
case, is executed on the thread from which is called. There are
certain things you must do to get other threads involved. Also,
classes don't get assigned to any particular thread so there isn't a
one-to-one relationship.
 
Back
Top