Browse Source

Do not indicate a line is waiting when scripting console is disposed.

pull/15/head
Matt Ward 14 years ago
parent
commit
d6d6d5a908
  1. 4
      src/AddIns/BackendBindings/Scripting/Project/Src/ThreadSafeScriptingConsoleEvents.cs
  2. 31
      src/AddIns/BackendBindings/Scripting/Test/Console/ThreadSafeScriptingConsoleEventsTests.cs
  3. 1
      src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj

4
src/AddIns/BackendBindings/Scripting/Project/Src/ThreadSafeScriptingConsoleEvents.cs

@ -9,14 +9,14 @@ namespace ICSharpCode.Scripting @@ -9,14 +9,14 @@ namespace ICSharpCode.Scripting
public class ThreadSafeScriptingConsoleEvents
{
// The index into the waitHandles array where the lineReceivedEvent is stored.
int lineReceivedEventIndex = 0;
int lineReceivedEventIndex = 1;
ManualResetEvent lineReceivedEvent = new ManualResetEvent(false);
ManualResetEvent disposedEvent = new ManualResetEvent(false);
WaitHandle[] waitHandles;
public ThreadSafeScriptingConsoleEvents()
{
waitHandles = new WaitHandle[] {lineReceivedEvent, disposedEvent};
waitHandles = new WaitHandle[] {disposedEvent, lineReceivedEvent};
}
public virtual bool WaitForLine()

31
src/AddIns/BackendBindings/Scripting/Test/Console/ThreadSafeScriptingConsoleEventsTests.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// 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 NUnit.Framework;
namespace ICSharpCode.Scripting.Tests.Console
{
[TestFixture]
public class ThreadSafeScriptingConsoleEventsTests
{
ThreadSafeScriptingConsoleEvents consoleEvents;
void CreateConsoleEvents()
{
consoleEvents = new ThreadSafeScriptingConsoleEvents();
}
[Test]
public void WaitForLine_DisposedEventSetAndLineReceivedEventSet_ReturnsFalse()
{
CreateConsoleEvents();
consoleEvents.SetLineReceivedEvent();
consoleEvents.SetDisposedEvent();
bool wait = consoleEvents.WaitForLine();
Assert.IsFalse(wait);
}
}
}

1
src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj

@ -93,6 +93,7 @@ @@ -93,6 +93,7 @@
<Compile Include="Console\SendLineToScriptingConsoleCommandTests.cs" />
<Compile Include="Console\SendSelectedTextToScriptingConsoleCommandTests.cs" />
<Compile Include="Console\SendToScriptingConsoleCommandTestsBase.cs" />
<Compile Include="Console\ThreadSafeScriptingConsoleEventsTests.cs" />
<Compile Include="Console\ThreadSafeScriptingConsoleTests.cs" />
<Compile Include="Console\TwoConsoleLinesWaitingTests.cs" />
<Compile Include="Designer\CallBeginInitOnLoadTests.cs" />

Loading…
Cancel
Save