Skip to content

Commit 5941626

Browse files
committed
Document TryWait overloads, and WaitResult enumeration.
1 parent 6183f6d commit 5941626

File tree

2 files changed

+75
-9
lines changed

2 files changed

+75
-9
lines changed

src/Renci.SshNet/ISession.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,27 @@ internal interface ISession : IDisposable
156156
/// </remarks>
157157
void WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout);
158158

159+
/// <summary>
160+
/// Waits for the specified <seec ref="WaitHandle"/> to receive a signal, using a <see cref="TimeSpan"/>
161+
/// to specify the time interval.
162+
/// </summary>
163+
/// <param name="waitHandle">The <see cref="WaitHandle"/> that should be signaled.</param>
164+
/// <param name="timeout">A <see cref="TimeSpan"/> that represents the number of milliseconds to wait, or a <see cref="TimeSpan"/> that represents <c>-1</c> milliseconds to wait indefinitely.</param>
165+
/// <param name="exception">When this method returns <see cref="WaitResult.Failed"/>, contains the <see cref="Exception"/>.</param>
166+
/// <returns>
167+
/// A <see cref="WaitResult"/>.
168+
/// </returns>
159169
WaitResult TryWait(WaitHandle waitHandle, TimeSpan timeout, out Exception exception);
160170

171+
/// <summary>
172+
/// Waits for the specified <seec ref="WaitHandle"/> to receive a signal, using a <see cref="TimeSpan"/>
173+
/// to specify the time interval.
174+
/// </summary>
175+
/// <param name="waitHandle">The <see cref="WaitHandle"/> that should be signaled.</param>
176+
/// <param name="timeout">A <see cref="TimeSpan"/> that represents the number of milliseconds to wait, or a <see cref="TimeSpan"/> that represents <c>-1</c> milliseconds to wait indefinitely.</param>
177+
/// <returns>
178+
/// A <see cref="WaitResult"/>.
179+
/// </returns>
161180
WaitResult TryWait(WaitHandle waitHandle, TimeSpan timeout);
162181

163182
/// <summary>

src/Renci.SshNet/Session.cs

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private uint NextChannelNumber
268268
/// <description>The <see cref="Session"/> is disposed.</description>
269269
/// </item>
270270
/// <item>
271-
/// <description>The SSH_MSG_DISCONNECT message - which is used to disconnect from the server - has been sent.</description>
271+
/// <description>The <c>SSH_MSG_DISCONNECT</c> message - which is used to disconnect from the server - has been sent.</description>
272272
/// </item>
273273
/// <item>
274274
/// <description>The client has not been authenticated successfully.</description>
@@ -798,17 +798,46 @@ internal void WaitOnHandle(WaitHandle waitHandle)
798798
WaitOnHandle(waitHandle, ConnectionInfo.Timeout);
799799
}
800800

801+
/// <summary>
802+
/// Waits for the specified <seec ref="WaitHandle"/> to receive a signal, using a <see cref="TimeSpan"/>
803+
/// to specify the time interval.
804+
/// </summary>
805+
/// <param name="waitHandle">The <see cref="WaitHandle"/> that should be signaled.</param>
806+
/// <param name="timeout">A <see cref="TimeSpan"/> that represents the number of milliseconds to wait, or a <see cref="TimeSpan"/> that represents <c>-1</c> milliseconds to wait indefinitely.</param>
807+
/// <returns>
808+
/// A <see cref="WaitResult"/>.
809+
/// </returns>
801810
WaitResult ISession.TryWait(WaitHandle waitHandle, TimeSpan timeout)
802811
{
803812
Exception exception;
804813
return TryWait(waitHandle, timeout, out exception);
805814
}
806815

816+
/// <summary>
817+
/// Waits for the specified <seec ref="WaitHandle"/> to receive a signal, using a <see cref="TimeSpan"/>
818+
/// to specify the time interval.
819+
/// </summary>
820+
/// <param name="waitHandle">The <see cref="WaitHandle"/> that should be signaled.</param>
821+
/// <param name="timeout">A <see cref="TimeSpan"/> that represents the number of milliseconds to wait, or a <see cref="TimeSpan"/> that represents <c>-1</c> milliseconds to wait indefinitely.</param>
822+
/// <param name="exception">When this method returns <see cref="WaitResult.Failed"/>, contains the <see cref="Exception"/>.</param>
823+
/// <returns>
824+
/// A <see cref="WaitResult"/>.
825+
/// </returns>
807826
WaitResult ISession.TryWait(WaitHandle waitHandle, TimeSpan timeout, out Exception exception)
808827
{
809828
return TryWait(waitHandle, timeout, out exception);
810829
}
811830

831+
/// <summary>
832+
/// Waits for the specified <seec ref="WaitHandle"/> to receive a signal, using a <see cref="TimeSpan"/>
833+
/// to specify the time interval.
834+
/// </summary>
835+
/// <param name="waitHandle">The <see cref="WaitHandle"/> that should be signaled.</param>
836+
/// <param name="timeout">A <see cref="TimeSpan"/> that represents the number of milliseconds to wait, or a <see cref="TimeSpan"/> that represents <c>-1</c> milliseconds to wait indefinitely.</param>
837+
/// <param name="exception">When this method returns <see cref="WaitResult.Failed"/>, contains the <see cref="Exception"/>.</param>
838+
/// <returns>
839+
/// A <see cref="WaitResult"/>.
840+
/// </returns>
812841
private WaitResult TryWait(WaitHandle waitHandle, TimeSpan timeout, out Exception exception)
813842
{
814843
if (waitHandle == null)
@@ -1157,7 +1186,7 @@ private void TrySendDisconnect(DisconnectReason reasonCode, string message)
11571186
_isDisconnectMessageSent = true;
11581187
}
11591188

1160-
#region Handle received message events
1189+
#region Handle received message events
11611190

11621191
/// <summary>
11631192
/// Called when <see cref="DisconnectMessage"/> received.
@@ -1579,7 +1608,7 @@ internal void OnChannelFailureReceived(ChannelFailureMessage message)
15791608
handlers(this, new MessageEventArgs<ChannelFailureMessage>(message));
15801609
}
15811610

1582-
#endregion
1611+
#endregion
15831612

15841613
private void KeyExchange_HostKeyReceived(object sender, HostKeyEventArgs e)
15851614
{
@@ -1588,7 +1617,7 @@ private void KeyExchange_HostKeyReceived(object sender, HostKeyEventArgs e)
15881617
handlers(this, e);
15891618
}
15901619

1591-
#region Message loading functions
1620+
#region Message loading functions
15921621

15931622
/// <summary>
15941623
/// Registers SSH message with the session.
@@ -1653,7 +1682,7 @@ internal static string ToHex(byte[] bytes)
16531682
return ToHex(bytes, 0);
16541683
}
16551684

1656-
#endregion
1685+
#endregion
16571686

16581687
/// <summary>
16591688
/// Establishes a socket connection to the specified host and port.
@@ -2322,7 +2351,7 @@ private static SshConnectionException CreateConnectionAbortedByServerException()
23222351
DisconnectReason.ConnectionLost);
23232352
}
23242353

2325-
#region IDisposable implementation
2354+
#region IDisposable implementation
23262355

23272356
private bool _disposed;
23282357

@@ -2413,9 +2442,9 @@ protected virtual void Dispose(bool disposing)
24132442
Dispose(false);
24142443
}
24152444

2416-
#endregion IDisposable implementation
2445+
#endregion IDisposable implementation
24172446

2418-
#region ISession implementation
2447+
#region ISession implementation
24192448

24202449
/// <summary>
24212450
/// Gets or sets the connection info.
@@ -2501,14 +2530,32 @@ bool ISession.TrySendMessage(Message message)
25012530
return TrySendMessage(message);
25022531
}
25032532

2504-
#endregion ISession implementation
2533+
#endregion ISession implementation
25052534
}
25062535

2536+
/// <summary>
2537+
/// Represents the result of a wait operations.
2538+
/// </summary>
25072539
internal enum WaitResult
25082540
{
2541+
/// <summary>
2542+
/// The <see cref="WaitHandle"/> was signaled within the specified interval.
2543+
/// </summary>
25092544
Success = 1,
2545+
2546+
/// <summary>
2547+
/// The <see cref="WaitHandle"/> was not signaled within the specified interval.
2548+
/// </summary>
25102549
TimedOut = 2,
2550+
2551+
/// <summary>
2552+
/// The session is in a disconnected state.
2553+
/// </summary>
25112554
Disconnected = 3,
2555+
2556+
/// <summary>
2557+
/// The session is in a failed state.
2558+
/// </summary>
25122559
Failed = 4
25132560
}
25142561
}

0 commit comments

Comments
 (0)