Added Stop() method to Gather to allow the gather to be shut down

This commit is contained in:
Heath Volmer
2016-09-26 08:36:08 -06:00
parent d5970f76ce
commit a99a69b4bb
7 changed files with 17 additions and 7 deletions

View File

@@ -65,7 +65,17 @@ namespace PepperDash.Core
{
Port = port;
StringDelimiter = delimiter;
port.TextReceived += TextReceivedStringDelimiter;
port.TextReceived += Port_TextReceivedStringDelimiter;
}
/// <summary>
/// Disconnects this gather from the Port's TextReceived event. This will not fire LineReceived
/// after the this call.
/// </summary>
public void Stop()
{
Port.TextReceived -= Port_TextReceived;
Port.TextReceived -= Port_TextReceivedStringDelimiter;
}
/// <summary>
@@ -93,7 +103,7 @@ namespace PepperDash.Core
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
void TextReceivedStringDelimiter(object sender, GenericCommMethodReceiveTextArgs args)
void Port_TextReceivedStringDelimiter(object sender, GenericCommMethodReceiveTextArgs args)
{
var handler = LineReceived;
if (handler != null)
@@ -118,7 +128,7 @@ namespace PepperDash.Core
/// </summary>
~CommunicationGather()
{
Port.TextReceived -= Port_TextReceived;
Stop();
}
}
}