Thread - Abort!!

  • Thread starter Thread starter Bjoern
  • Start date Start date
B

Bjoern

Hi all,
how can i handle the thread-abort in the compactframework.
e.g.

TcpListener listener = null;
public static main()
{
Thread th = new Thread(new ThreadStart(Run));
th.Start();
....
...
...
if(....)
th.Abort(); !!!Error!!! This funktion do not exist
}

public void Run()
{
while(true)
{
.....
// AcceptTcpClient stops the thread and waits for an incoming Client
TcpClient c = listener.AcceptTcpClient();
...
}
}

How can i now abort the Thread Run???
Second question how can i start and close a listener with two buttons??
Everytime the exception: "normally each Socketadress could be used one time" comes.
Thx
 
Hi Bjoern,

The thread aborts when it returns from the called procedure so typically
developers set a global flag that signals to all threads that a shutdown is
requested. See the following HOWTO for an example...

http://msdn.microsoft.com/library/en-us/dncfhowto/html/stopmt.asp

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Bjoern, Thread.Abort is not supported by the .NET Compact Framework. See
this "thread" for more info:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=6a2019b368c7883f&rnum=1

And also this HOWTO for a workaround:
http://msdn.microsoft.com/mobility/...pull=/library/en-us/dncfhowto/html/stopmt.asp

-j
--
Jonathan Wells
Product Manager
..NET Compact Framework
Check out the .NET Compact Framework FAQ at:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top