A
Arafangion
Hello, recently I've been trying to figure out how the heck to just
destroy a thread.
I have since rewritten the code in question, but what I was trying to do
was to use the .Abort() method, but that would fail if the thread was in
a Suspended case.
Now, my book doesn't even hint (Deitel Developer Series, C# for
Experienced Programmers) that a thread might exist in more than one
state, which was also part of my problem. (Fortunately during a period
of high inspiration I managed to figure out that ThreadState is a
bitfield and OR'ing the threadstates work).
However, it appears to be impossible to do the following:
For a given thread, stop it.
I have tried exhaustively checking the state of the thread and doing the
appropriate .Resume(), .Interrupt(), etc, however by the time I do
..Abort(), I cannot guarantee that the statement will execute successfully.
Currently I've implemented my very own .AbortRedrawing() method, but
I've wasted hours trying to understand threads themselves. I do not
understand why there's no .ForceAbort() method.
If anyone could show me some documentation (more useful than the "wow,
here's how to create three threads!" kind of tutorial), that'd be great.
(Sorry if the tone is a bit... But I've been wrestling with it for a
while).
Thanksyou.
(PS: I have since discovered the Timer() class, which would've fit my
purpose better, but the fact stands that I still need to learn more
about threading in .NET)
destroy a thread.
I have since rewritten the code in question, but what I was trying to do
was to use the .Abort() method, but that would fail if the thread was in
a Suspended case.
Now, my book doesn't even hint (Deitel Developer Series, C# for
Experienced Programmers) that a thread might exist in more than one
state, which was also part of my problem. (Fortunately during a period
of high inspiration I managed to figure out that ThreadState is a
bitfield and OR'ing the threadstates work).
However, it appears to be impossible to do the following:
For a given thread, stop it.
I have tried exhaustively checking the state of the thread and doing the
appropriate .Resume(), .Interrupt(), etc, however by the time I do
..Abort(), I cannot guarantee that the statement will execute successfully.
Currently I've implemented my very own .AbortRedrawing() method, but
I've wasted hours trying to understand threads themselves. I do not
understand why there's no .ForceAbort() method.
If anyone could show me some documentation (more useful than the "wow,
here's how to create three threads!" kind of tutorial), that'd be great.
(Sorry if the tone is a bit... But I've been wrestling with it for a
while).
Thanksyou.
(PS: I have since discovered the Timer() class, which would've fit my
purpose better, but the fact stands that I still need to learn more
about threading in .NET)