CmisSync.Lib.Streams.PausableStream.Pause C# (CSharp) Method

Pause() public method

Pause this stream until resume is called.
public Pause ( ) : void
return void
        public void Pause() {
            this.waitHandle.Reset();
        }

Usage Example

コード例 #1
0
 public void PausableStreamDoesPauseAndResumeOnMultiplePauseCalls([Values(1)]int seconds) {
     int length = 1024 * 1024 * 10;
     var start = DateTime.Now;
     byte[] content = new byte[length];
     using (var inputStream = new MemoryStream(content))
         using (var underTest = new PausableStream(inputStream)) {
         underTest.Pause();
         underTest.Pause();
         underTest.Pause();
         underTest.Pause();
         var task = Task.Factory.StartNew(() => {
             using (var outputStream = new MemoryStream()) {
                 underTest.CopyTo(outputStream);
                 Assert.That(outputStream.Length, Is.EqualTo(length));
                 var duration = DateTime.Now - start;
                 Assert.That(Math.Round(duration.TotalSeconds), Is.InRange(seconds, seconds + 1));
             }
         });
         System.Threading.Thread.Sleep(seconds * 1000);
         underTest.Resume();
         underTest.Resume();
         task.Wait();
     }
 }