3 changed files with 45 additions and 1 deletions
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Threading; |
||||
using System.Windows; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.AvalonEdit |
||||
{ |
||||
[TestFixture] |
||||
public class MultipleUIThreads |
||||
{ |
||||
Exception error; |
||||
|
||||
[Test] |
||||
public void CreateEditorInstancesOnMultipleUIThreads() |
||||
{ |
||||
Thread t1 = new Thread(new ThreadStart(Run)); |
||||
Thread t2 = new Thread(new ThreadStart(Run)); |
||||
t1.SetApartmentState(ApartmentState.STA); |
||||
t2.SetApartmentState(ApartmentState.STA); |
||||
t1.Start(); |
||||
t2.Start(); |
||||
t1.Join(); |
||||
t2.Join(); |
||||
if (error != null) |
||||
throw new InvalidOperationException(error.Message, error); |
||||
} |
||||
|
||||
[STAThread] |
||||
void Run() |
||||
{ |
||||
try { |
||||
var window = new Window(); |
||||
window.Content = new TextEditor(); |
||||
window.Show(); |
||||
} catch (Exception ex) { |
||||
error = ex; |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue