本文整理汇总了C#中Subject.Wait方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.Wait方法的具体用法?C# Subject.Wait怎么用?C# Subject.Wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.Wait方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Wait
public void Wait()
{
var subject = new Subject<int>();
Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(1));
subject.OnNext(100);
subject.OnCompleted();
});
subject.Wait().Is(100);
}
示例2: Wait
public void Wait()
{
#if !UNITY_METRO
var subject = new Subject<int>();
ThreadPool.QueueUserWorkItem(_ =>
{
Thread.Sleep(TimeSpan.FromSeconds(1));
subject.OnNext(100);
subject.OnCompleted();
});
subject.Wait().Is(100);
#endif
}
示例3: Wait
public void Wait()
{
SetScehdulerForImport();
#if !UNITY_METRO
var subject = new Subject<int>();
ThreadPool.QueueUserWorkItem(_ =>
{
Thread.Sleep(TimeSpan.FromSeconds(1));
subject.OnNext(100);
subject.OnCompleted();
});
subject.Wait().Is(100);
#endif
UniRx.Scheduler.SetDefaultForUnity();
}
示例4: Request
public void Request(Uri uri)
{
Console.WriteLine("############################################################");
// request
var request = new HttpRequest(uri);
request.EnableEncoding();
request.SetKeepAlive(true);
Console.Write(request.ToString());
#if USE_BYTES_BODY
using (var subject = new ChunkedHttpResponseObserver())
{
var body = new Subject<IList<Byte>>();
body.Subscribe(x =>
{
Console.WriteLine("body: " + x.Count + " bytes");
}
, ex =>
{
Console.WriteLine(ex);
}
, () =>
{
Console.WriteLine("body end");
});
subject.BodyObservable.Subscribe(body);
bool keepAlive = true;
subject.KeepAliveObservalbe
.Subscribe(x =>
{
// disconnect
keepAlive = x;
});
#else
using (var subject = new HttpRawByteSubject())
{
var body = new Subject<Byte>();
var buffer = new List<Byte>();
body.Subscribe(x =>
{
buffer.Add(x);
}
, ex =>
{
Console.WriteLine(ex);
}
, () =>
{
Console.WriteLine("body: " + buffer.Count + " bytes");
Console.WriteLine("body end");
});
subject.BodyObservable.Subscribe(body);
#endif
// statusline
subject.StatusObservable.Subscribe(x =>
{
Console.WriteLine("status: " + x);
});
// response headers
subject.HeaderObservable.Subscribe(x =>
{
Console.WriteLine(x.Key + ": " + x.Value);
}
, () =>
{
Console.WriteLine();
}
);
////////////////////////////
// connect
////////////////////////////
GetConnection(uri)
.Subscribe(x =>
{
// ready to read
subject.OnNext(x);
// send request
x.SendRequestObservable(request)
.Subscribe(_ =>
{
});
}
, subject.OnError
)
;
// wait...
body.Wait();
if (!keepAlive)
{
Close();
}
//.........这里部分代码省略.........