Home > Net >  Why in c # is to operate the main thread will be terminated before the start of the child thread
Why in c # is to operate the main thread will be terminated before the start of the child thread

Time:03-24

ClientSocketBarCode=new clientSocketBarCode (" 127.0.0.1 ", 5555);
ThreadStart barCodeThreadStart=new ThreadStart (clientSocketBarCode ConnectStart);
BarCodeThread=new Thread (barCodeThreadStart);

BarCodeThread. Start ();
MessageBox. Show (barCodeThread. ThreadState. ToString ());//output thread state here is: Running
MessageBox. Show (barCodeThread. ThreadState. ToString ());//while here becomes: Stopped

CodePudding user response:

Isn't it normal execution has completed?

CodePudding user response:

ClientSocketBarCode. ConnectStart

You have to code?? If you own this ConnectStart, code wrote a this

Var a=1;

So, he is not a word was performed, performed, you still no thread closed??
  •  Tags:  
  • C#
  • Related