Method RetrieveAsync
- Namespace
- DotNetBrowser.Cast
- Assembly
- DotNetBrowser.dll
RetrieveAsync(Predicate<IMediaReceiver>, TimeSpan)
Waiting till the first receiver matching the predicate
is discovered.
Task<IMediaReceiver> RetrieveAsync(Predicate<IMediaReceiver> predicate, TimeSpan timeout)
Parameters
predicate
Predicate<IMediaReceiver>The predicated media receiver.
timeout
TimeSpanThe predefined timeout.
Returns
- Task<IMediaReceiver>
The task that can be used to wait for completion and obtain the result with the first discovered receiver matching the
predicate
.
Remarks
If a matching receiver has already been discovered, returns it immediately.
Example of usage:
browser.Cast.StartPresentationHandler =
new AsyncHandler<StartPresentationParameters, StartPresentationResponse>(async p =>
{
IMediaReceiver mediaReceiver
= await p.MediaReceivers
.RetrieveAsync(receiver => receiver.Name.Contains("Samsung TV"), timeout);
return StartPresentationResponse.Start(mediaReceiver);
});
Exceptions
- ReceiverNotDiscoveredException
When the receiver has not been discovered within
timeout
.
RetrieveAsync(Predicate<IMediaReceiver>)
Waiting till the first receiver matching the predicate
is discovered.
Task<IMediaReceiver> RetrieveAsync(Predicate<IMediaReceiver> predicate)
Parameters
predicate
Predicate<IMediaReceiver>The predicated media receiver.
Returns
- Task<IMediaReceiver>
The task that can be used to wait for completion and obtain the result with the first discovered receiver matching the
predicate
.
Remarks
If a matching receiver has already been discovered, returns it immediately.
Example of usage:
browser.Cast.StartPresentationHandler =
new AsyncHandler<StartPresentationParameters, StartPresentationResponse>(async p =>
{
IMediaReceiver mediaReceiver
= await p.MediaReceivers
.RetrieveAsync(receiver => receiver.Name.Contains("Samsung TV"));
return StartPresentationResponse.Start(mediaReceiver);
});
Exceptions
- ReceiverNotDiscoveredException
When the receiver has not been discovered within 45 seconds.