Task is not executed

I am in an MVC application, and try to install a software in a remote server, by launching a WCF function in that server; WCF is hosted in a Windows service.

Since the installation process takes a long time, I execute it asynchronously, like this:

ChannelFactory factory = new ChannelFactory<MyClass>(binding, address);
MyClass channel = factory.CreateChannel();
Task task = new Task(() => { channel.LongTimeFunction(); });

In this way, the LongTimeFunction isn't executed at all.

It's the first time that I use the Task class, maybe there's something that I am missing?


After Starting a task you should wait for it to be completed,unless your code will be returned while the LongTimeFunction function is still not completed. Here is a good example http://msdn.microsoft.com/en-us/library/dd537610(v=vs.110).aspx .

Need Your Help

How to change the function parameter to point?

c++ pointers recursion

I want to modify the following code, changing the Input to a pointer.

WCF Restful Web Service Endpoint exposed but methods all return http 404 not found c#

c# asp.net web-services wcf https

I have written my first Web Service and when I test run it from visual studio on my local development machine everything works as expected. I went to the clients to deploy the service and found that