You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1016 B
44 lines
1016 B
// 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.ShowActivated = false; |
|
window.Show(); |
|
} catch (Exception ex) { |
|
error = ex; |
|
} |
|
} |
|
} |
|
}
|
|
|