MudassarRasool / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

PLinq causes a errors unloading app domain #795

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. System.Threading.Parallel calls (sample code below)

What is the expected output? What do you see instead?
Unit test batch finishes then produces a System.AppDomainUnloadedException:

Unhandled Exception:Unhandled Exception:Unhandled Exception:Unhandled Exception:
Unhandled Exception:Unhandled Exception:  System.AppDomainUnloadedException: The
 application domain in which the thread was running has been unloaded.
System.AppDomainUnloadedException: The application domain in which the thread wa
s running has been unloaded.
 System.AppDomainUnloadedException: The application domain in which the thread w
as running has been unloaded.
 System.AppDomainUnloadedException: The application domain in which the thread w
as running has been unloaded.
 System.AppDomainUnloadedException: The application domain in which the thread w
as running has been unloaded.
 System.AppDomainUnloadedException: The application domain in which the thread w
as running has been unloaded.

Unhandled Exception: System.AppDomainUnloadedException: The application domain i
n which the thread was running has been unloaded.

What version of the product are you using? On what operating system?
676

Please provide any additional information below.

Exact test that produces the problem:
(Note that System.Threading, as referenced below, is actually the Parallels 
library (System.Threading.Parallel) that performs iterations in multiple 
threads.

http://msdn.microsoft.com/en-us/library/system.threading.tasks.parallel.aspx
http://sourceforge.net/projects/cli-parallel/)

using System;
using System.Collections.Generic;
using System.Threading;
using MbUnit.Framework;

namespace DeployMaster.Tests
{
    [TestFixture]
    public class ParallelExtensionsTest
    {
        /**
         * Parallel test kills Gallio.
         */

        [ThreadStatic]
        private string completeString;

        [Test]
        [Category("IntegrationTest")]
        public void AppendIntegers()
        {
            completeString = "";
            IList<int> integers = new List<int>();
            for (int i = 1; i <= 100; i++)
            {
                integers.Add(i);
            }

            Parallel.ForEach(integers, integer =>
                {
                    completeString += (integer + "_");
                });
            Console.WriteLine(completeString);
        }
    }
}

Original issue reported on code.google.com by jbalfa...@gmail.com on 4 Jan 2011 at 5:01

GoogleCodeExporter commented 8 years ago
Please contact me at jbalfantz@gmail.com for more information.

Joe

Original comment by jbalfa...@gmail.com on 4 Jan 2011 at 5:02

GoogleCodeExporter commented 8 years ago
Odd. I can't reproduce the problem. The test passes as expected and produces 
the following output: 

"1_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_19_20_21_22_23_24_25_26_27_28_29_30_
31_32_33_34_35_36_37_38_39_40_41_42_43_44_45_46_47_48_49_50_52_53_54_55_56_57_58
_59_60_61_62_63_64_65_66_67_68_69_70_71_72_73_74_75_76_77_78_79_80_81_82_83_84_8
5_86_87_88_89_90_91_92_93_94_95_96_97_98_99_100_2_51_"

I'm using Gallio v3.3 build 171 (nightly build)

I will switch back to v3.2 and see if the error occurs. Maybe something was 
fixed in the meantime. I can't remember.

Original comment by Yann.Tre...@gmail.com on 5 Jan 2011 at 6:59