TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ravi Kiran Chanduri
671
1.4k
1.3m
not executing code after Task in async/await programming
Dec 26 2019 10:45 AM
Hi ,
I am trying to understand the actual use of asyn/await in c# and have gone through few articles and tried with an example as below.
class
Program
{
static
void
Main(
string
[] args)
{
Program p =
new
Program();
p.MethodOne();
p.MethodTwo();
p.MethodThree();
}
public
void
MethodOne()
{
Console.WriteLine(
"methodone has been called"
);
}
public
async Task MethodTwo()
{
Task<
string
> delayingMethodCall =
new
Task<
string
>(DelayingMethod);
Console.WriteLine(
"methodTwo call started"
);
string
message = await delayingMethodCall;
Console.WriteLine(message);
Console.WriteLine(
"methodTwo called"
);
Console.ReadKey();
}
public
void
MethodThree()
{
Console.WriteLine(
"methodThree has been called"
);
}
public
string
DelayingMethod()
{
System.Threading.Thread.Sleep(5000);
return
"Delayed Process is done"
;
}
}
I am able to see third method's result , but the code after string message = await delayingMethodCall;
is not executing.
Can someone explain me the issue here?
Thanks in Advance
Ravi.
Reply
Answers (
3
)
New to C# and want to know where and how to start
What is exact used of Native Methods ? Where it will be used