Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/monotouch-test/CoreAnimation/LayerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ public void TestBug26532 ()
} catch (Exception e) {
ex = e;
}
});
}) {
IsBackground = true,
};
thread.Start ();
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (10)), Is.True, "Thread.Join timed out");
Comment on lines 137 to +138

var watch = new Stopwatch ();
watch.Start ();
Expand Down Expand Up @@ -181,7 +183,7 @@ public void TestCALayerDelegateDispose ()
IsBackground = true,
};
t.Start ();
t.Join ();
Assert.That (t.Join (TimeSpan.FromSeconds (5)), Is.True, "Thread.Join timed out");
GC.Collect ();

NSRunLoop.Main.RunUntil (NSDate.Now.AddSeconds (0.1));
Expand Down
6 changes: 4 additions & 2 deletions tests/monotouch-test/CoreImage/CIKernelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ public void CIKernel_BasicTest ()
} catch (Exception ex2) {
ex = ex2;
}
});
}) {
IsBackground = true,
};
t.Start ();
t.Join ();
Assert.That (t.Join (TimeSpan.FromSeconds (30)), Is.True, "Thread.Join timed out");
Comment on lines 159 to +160
if (ex is not null)
throw ex;
}
Expand Down
6 changes: 4 additions & 2 deletions tests/monotouch-test/Foundation/NSStreamTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public void ConnectToHost ()
return;
}

var listenThread = new Thread (new ParameterizedThreadStart (DebugListener));
var listenThread = new Thread (new ParameterizedThreadStart (DebugListener)) {
IsBackground = true,
};
listenThread.Start (listener);
NSStream.CreatePairWithSocketToHost (new IPEndPoint (IPAddress.Loopback, port), out read, out write);
read.Open ();
Expand All @@ -74,7 +76,7 @@ public void ConnectToHost ()
Assert.That (read.Read (result, 5), Is.EqualTo ((nint) 5));
for (int i = 0; i < 5; i++)
Assert.That (result [i], Is.EqualTo (send [i] * 10));
listenThread.Join ();
Assert.That (listenThread.Join (TimeSpan.FromSeconds (10)), Is.True, "listenThread.Join timed out");
listener.Stop ();
read.Close ();
write.Close ();
Comment on lines 78 to 82
Expand Down
2 changes: 1 addition & 1 deletion tests/monotouch-test/Foundation/NotificationCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void ThreadSafe ()
// OK, we're done now, time to stop.
stopSignal.Set ();
for (var i = 0; i < threadCount; i++) {
threads [i].Join ();
Assert.That (threads [i].Join (TimeSpan.FromSeconds (5)), Is.True, $"Thread {i} failed to join within 5 seconds");
}
Assert.That (ex, Is.Null, "Exception");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/monotouch-test/Foundation/ThreadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void GetEntryAssemblyReturnsOk ()
IsBackground = true,
};
t.Start ();
t.Join ();
Assert.That (t.Join (TimeSpan.FromSeconds (5)), Is.True, "Thread.Join timed out");
Assert.That (rv, Is.EqualTo (0));
}

Expand Down
6 changes: 3 additions & 3 deletions tests/monotouch-test/Foundation/TimerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void Bug17793 ()
thread.Start ();

Assert.That (evt.Wait (TimeSpan.FromSeconds (5)), Is.True, "Not signalled twice in 5s");
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (10)), Is.True, "Thread.Join timed out");
}
}

Expand Down Expand Up @@ -70,7 +70,7 @@ public void Bug2443 ()
thread.Start ();

Assert.That (evt.Wait (TimeSpan.FromSeconds (5)), Is.True, "Not signalled twice in 5s");
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (10)), Is.True, "Thread.Join timed out");
}
}

Expand Down Expand Up @@ -101,7 +101,7 @@ public void CreateTimer_NewSignature ()

Assert.That (evt.WaitOne (TimeSpan.FromSeconds (5)), Is.True, "WaitOne");
Assert.That (result, Is.True, "result");
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (10)), Is.True, "Thread.Join timed out");
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions tests/monotouch-test/ObjCRuntime/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2122,9 +2122,11 @@ public void BlockCollection ()
} catch (Exception e) {
ex = e;
}
});
}) {
IsBackground = true,
};
thread.Start ();
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (30)), Is.True, "Thread.Join timed out");
Comment on lines 2128 to +2129
GC.Collect ();
GC.WaitForPendingFinalizers ();
TestRuntime.RunAsync (TimeSpan.FromSeconds (30), () => { }, () => ObjCBlockTester.FreedBlockCount > initialFreedCount);
Expand Down
10 changes: 6 additions & 4 deletions tests/monotouch-test/ObjCRuntime/RuntimeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public bool UsableUntilDeadImpl ()
IsBackground = true,
};
t.Start ();
t.Join ();
Assert.That (t.Join (TimeSpan.FromSeconds (5)), Is.True, "Thread.Join timed out");

// Now we have a handle to an object that may be garbage collected at any time.
int counter = 0;
Expand Down Expand Up @@ -297,7 +297,7 @@ public void FinalizationRaceCondition ()
IsBackground = true
};
thread.Start ();
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (5)), Is.True, "Thread.Join timed out");

var getter1 = new Func<string, string> ((key) => dict [key] as NSString);
var getter2 = new Func<string, NSString> ((key) => dict [key] as NSString);
Expand Down Expand Up @@ -555,9 +555,11 @@ public void ResurrectedObjectsDisposedTest (Type type)
var t1 = new Thread (() => {
for (int i = 0; i < objects.Length; i++)
Messaging.bool_objc_msgSend_IntPtr_int (invokerClassHandle, Selector.GetHandle ("invokeMe:wait:"), objects [i], 0);
});
}) {
IsBackground = true,
};
t1.Start ();
t1.Join ();
Assert.That (t1.Join (TimeSpan.FromSeconds (5)), Is.True, "Thread.Join timed out");
Comment on lines 561 to +562

// Collect all those managed wrappers, and make sure their finalizers are executed.
GC.Collect ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,12 @@ public void SetNotification_GCHandleFreed ()
// Dispose to ensure GCHandle is freed
reachability.Dispose ();
}
});
}) {
IsBackground = true,
};

thread.Start ();
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (5)), Is.True, "Thread.Join timed out");
Comment on lines 227 to +228

// Force garbage collection
GC.Collect ();
Expand Down Expand Up @@ -263,10 +265,12 @@ public void SetNotification_GCHandleFreedWithNull ()
// Store weak reference to track if object is collected
weakRefs [i] = new WeakReference (reachability);
}
});
}) {
IsBackground = true,
};

thread.Start ();
thread.Join ();
Assert.That (thread.Join (TimeSpan.FromSeconds (5)), Is.True, "Thread.Join timed out");
Comment on lines 272 to +273

// Force garbage collection
GC.Collect ();
Expand Down
Loading