How can to set the wait time await result [duplicate]
This question already has an answer here:
Asynchronously wait for Task<T> to complete with timeout
12 answers
I have in my ms bot framework:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
context.Wait(MessageReceivedAsync);
}
How can I to set the wait time await result
?
c# async-await botframework
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 11:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Asynchronously wait for Task<T> to complete with timeout
12 answers
I have in my ms bot framework:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
context.Wait(MessageReceivedAsync);
}
How can I to set the wait time await result
?
c# async-await botframework
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 11:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Asynchronously wait for Task<T> to complete with timeout
12 answers
I have in my ms bot framework:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
context.Wait(MessageReceivedAsync);
}
How can I to set the wait time await result
?
c# async-await botframework
This question already has an answer here:
Asynchronously wait for Task<T> to complete with timeout
12 answers
I have in my ms bot framework:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
context.Wait(MessageReceivedAsync);
}
How can I to set the wait time await result
?
This question already has an answer here:
Asynchronously wait for Task<T> to complete with timeout
12 answers
c# async-await botframework
c# async-await botframework
edited Jan 1 at 10:02
Nkosi
117k17134200
117k17134200
asked Jan 1 at 9:50
M.TonyM.Tony
62
62
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 11:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 11:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I suggest you try something like the following:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
// Set the delay to whatever timeout interval you need (in milliseconds)
if (Task.WaitAny(result.ToTask(), Task.Delay(1000)) == result)
{
var activity = await result as Activity;
}
else
{
// Didn't complete during the defined interval
}
context.Wait(MessageReceivedAsync);
}
Update
Added usage of ToTask() to transform the IAwaitable
to a Task
that can be used with WhenAny
.
Hope it helps!
Thakns man, but I have error in string 'if (Task.WaitAny(result, Task.Delay(1000)) == result)' - Argument 1: Cannot convert from "Microsoft.Bot.Builder.Dialogs.IAwaitable <object>" to "System.Threading.Tasks.Task". I think convert would not be a good idea.
– M.Tony
Jan 1 at 10:13
1
See update on how to transform theIAwaitable
to aTask
– Itay Podhajcer
Jan 1 at 10:29
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I suggest you try something like the following:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
// Set the delay to whatever timeout interval you need (in milliseconds)
if (Task.WaitAny(result.ToTask(), Task.Delay(1000)) == result)
{
var activity = await result as Activity;
}
else
{
// Didn't complete during the defined interval
}
context.Wait(MessageReceivedAsync);
}
Update
Added usage of ToTask() to transform the IAwaitable
to a Task
that can be used with WhenAny
.
Hope it helps!
Thakns man, but I have error in string 'if (Task.WaitAny(result, Task.Delay(1000)) == result)' - Argument 1: Cannot convert from "Microsoft.Bot.Builder.Dialogs.IAwaitable <object>" to "System.Threading.Tasks.Task". I think convert would not be a good idea.
– M.Tony
Jan 1 at 10:13
1
See update on how to transform theIAwaitable
to aTask
– Itay Podhajcer
Jan 1 at 10:29
add a comment |
I suggest you try something like the following:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
// Set the delay to whatever timeout interval you need (in milliseconds)
if (Task.WaitAny(result.ToTask(), Task.Delay(1000)) == result)
{
var activity = await result as Activity;
}
else
{
// Didn't complete during the defined interval
}
context.Wait(MessageReceivedAsync);
}
Update
Added usage of ToTask() to transform the IAwaitable
to a Task
that can be used with WhenAny
.
Hope it helps!
Thakns man, but I have error in string 'if (Task.WaitAny(result, Task.Delay(1000)) == result)' - Argument 1: Cannot convert from "Microsoft.Bot.Builder.Dialogs.IAwaitable <object>" to "System.Threading.Tasks.Task". I think convert would not be a good idea.
– M.Tony
Jan 1 at 10:13
1
See update on how to transform theIAwaitable
to aTask
– Itay Podhajcer
Jan 1 at 10:29
add a comment |
I suggest you try something like the following:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
// Set the delay to whatever timeout interval you need (in milliseconds)
if (Task.WaitAny(result.ToTask(), Task.Delay(1000)) == result)
{
var activity = await result as Activity;
}
else
{
// Didn't complete during the defined interval
}
context.Wait(MessageReceivedAsync);
}
Update
Added usage of ToTask() to transform the IAwaitable
to a Task
that can be used with WhenAny
.
Hope it helps!
I suggest you try something like the following:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
// Set the delay to whatever timeout interval you need (in milliseconds)
if (Task.WaitAny(result.ToTask(), Task.Delay(1000)) == result)
{
var activity = await result as Activity;
}
else
{
// Didn't complete during the defined interval
}
context.Wait(MessageReceivedAsync);
}
Update
Added usage of ToTask() to transform the IAwaitable
to a Task
that can be used with WhenAny
.
Hope it helps!
edited Jan 1 at 10:28
answered Jan 1 at 10:01
Itay PodhajcerItay Podhajcer
2,0091413
2,0091413
Thakns man, but I have error in string 'if (Task.WaitAny(result, Task.Delay(1000)) == result)' - Argument 1: Cannot convert from "Microsoft.Bot.Builder.Dialogs.IAwaitable <object>" to "System.Threading.Tasks.Task". I think convert would not be a good idea.
– M.Tony
Jan 1 at 10:13
1
See update on how to transform theIAwaitable
to aTask
– Itay Podhajcer
Jan 1 at 10:29
add a comment |
Thakns man, but I have error in string 'if (Task.WaitAny(result, Task.Delay(1000)) == result)' - Argument 1: Cannot convert from "Microsoft.Bot.Builder.Dialogs.IAwaitable <object>" to "System.Threading.Tasks.Task". I think convert would not be a good idea.
– M.Tony
Jan 1 at 10:13
1
See update on how to transform theIAwaitable
to aTask
– Itay Podhajcer
Jan 1 at 10:29
Thakns man, but I have error in string 'if (Task.WaitAny(result, Task.Delay(1000)) == result)' - Argument 1: Cannot convert from "Microsoft.Bot.Builder.Dialogs.IAwaitable <object>" to "System.Threading.Tasks.Task". I think convert would not be a good idea.
– M.Tony
Jan 1 at 10:13
Thakns man, but I have error in string 'if (Task.WaitAny(result, Task.Delay(1000)) == result)' - Argument 1: Cannot convert from "Microsoft.Bot.Builder.Dialogs.IAwaitable <object>" to "System.Threading.Tasks.Task". I think convert would not be a good idea.
– M.Tony
Jan 1 at 10:13
1
1
See update on how to transform the
IAwaitable
to a Task
– Itay Podhajcer
Jan 1 at 10:29
See update on how to transform the
IAwaitable
to a Task
– Itay Podhajcer
Jan 1 at 10:29
add a comment |