[Mono-dev] Issues with Thread.CurrentThread on 4.2

Zoltan Varga vargaz at gmail.com
Fri Nov 13 03:22:03 UTC 2015


Hi,

  Reported as:
https://bugzilla.xamarin.com/show_bug.cgi?id=35828
        Zoltan

On Thu, Nov 12, 2015 at 12:42 PM, Martin Potter <Martin.Potter at faithlife.com
> wrote:

> We have some code which works on Microsoft’s runtime and used to work on
> Mono 3.12, but now fails on Mono 4.2. Simplified code to reproduce the
> issue is as follows:
>
> public class WorkStateThread
> {
> public void Start()
> {
> m_thread = new Thread(ThreadProc);
> m_thread.Start(Thread.CurrentThread);
> m_thread.Join();
> }
>
> private void ThreadProc (object objData)
> {
> if (m_thread != Thread.CurrentThread)
> throw new InvalidOperationException ("m_thread != Thread.CurrentThread");
> }
>
> Thread m_thread;
> }
>
> class MainClass
> {
> public static void Main (string[] args)
> {
> WorkStateThread ws = new WorkStateThread ();
> ws.Start ();
> Console.WriteLine ("Done");
> }
> }
>
> [TestFixture]
> public class Test
> {
> [Test]
> public void TestCase ()
> {
> WorkStateThread ws = new WorkStateThread ();
> ws.Start ();
> }
> }
>
> This code runs as expected when run from the command line, but if run as
> part of a unit test using NUnit, the InvalidOperationException is thrown.
>
> — Martin
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20151112/e5fa0a62/attachment.html>


More information about the Mono-devel-list mailing list