Multithreading

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.
 
T

Tom Porterfield

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.
 
A

Andy

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.
 
B

Brian Gideon

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top