Timeout.aml 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <topic id="b9451bd3-f759-4964-8f42-b48b06c19dca" revisionNumber="1">
  3. <developerHowToDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
  4. <title>Command execution</title>
  5. <content>
  6. When you need to terminte the command after specific time has passed you can use <codeEntityReference>P:Renci.SshNet.SshCommand.CommandTimeout</codeEntityReference> property.
  7. To specify time out property you must to create <codeEntityReference>T:Renci.SshNet.SshCommand</codeEntityReference> first.
  8. <para>See examples below:</para>
  9. <codeExample>
  10. <list class="ordered">
  11. <listItem>
  12. <para>Execute command and specify 10 sec timeout</para>
  13. <code language="cs">
  14. using (var client = new SshClient("host", "username", "password"))
  15. {
  16. client.Connect();
  17. var cmd = client.CreateCommand("sleep 10s");
  18. cmd.CommandTimeout = TimeSpan.FromSeconds(5);
  19. cmd.Execute();
  20. client.Disconnect();
  21. }
  22. </code>
  23. </listItem>
  24. </list>
  25. </codeExample>
  26. </content>
  27. <relatedTopics>
  28. <codeEntityReference>P:Renci.SshNet.SshCommand.CommandTimeout</codeEntityReference>
  29. <codeEntityReference>T:Renci.SshNet.SshCommand</codeEntityReference>
  30. </relatedTopics>
  31. </developerHowToDocument>
  32. </topic>