Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDick Porter <dick@acm.org>2007-09-07 17:27:23 +0400
committerDick Porter <dick@acm.org>2007-09-07 17:27:23 +0400
commitd872700d7523d17b90b64619599f8bbd8c1abcff (patch)
tree1d5cb0ee713c6a56a8de832d3fa8326316dac0e7 /mcs/class/System/System.Timers/Timer.cs
parent753ef658e140bd4204568b706eaf9b55779d3ba2 (diff)
2007-09-07 Dick Porter <dick@ximian.com>
* Timer.cs: This calls Thread methods in the finalizer too, so use the same workaround as in r85425. svn path=/trunk/mcs/; revision=85474
Diffstat (limited to 'mcs/class/System/System.Timers/Timer.cs')
-rw-r--r--mcs/class/System/System.Timers/Timer.cs12
1 files changed, 9 insertions, 3 deletions
diff --git a/mcs/class/System/System.Timers/Timer.cs b/mcs/class/System/System.Timers/Timer.cs
index b283441bd7f..ca4876f0bfe 100644
--- a/mcs/class/System/System.Timers/Timer.cs
+++ b/mcs/class/System/System.Timers/Timer.cs
@@ -45,7 +45,7 @@ namespace System.Timers
double interval;
ISynchronizeInvoke so;
ManualResetEvent wait;
- Thread thread;
+ WeakReference weak_thread;
readonly object locker = new object ();
[Category("Behavior")]
@@ -93,7 +93,9 @@ namespace System.Timers
if (value) {
exiting = false;
wait = new ManualResetEvent (false);
- thread = new Thread (new ThreadStart (StartTimer));
+ Thread thread = new Thread (new ThreadStart (StartTimer));
+ weak_thread = new WeakReference (thread);
+
thread.IsBackground = true;
thread.Start ();
} else {
@@ -210,7 +212,11 @@ namespace System.Timers
// the sleep speeds up the join under linux
Thread.Sleep (0);
- thread.Join ();
+
+ Thread thread = (Thread)weak_thread.Target;
+
+ if (thread != null)
+ thread.Join ();
}
}
}