user
user

Reputation: 246

Sending a message first and then executing code

We are developing an iPhone app (for shopping) and have a dotnet application which takes the request coming from the iphone and processes them.

    //How it works

So I need to return a message even before the transaction is processed (to make it more user friendly and not to annoy them by the delay caused for the entire process). After the message is sent it should proceed to actual payment process. How can I do this?

Upvotes: 0

Views: 69

Answers (2)

Mahmoud Moravej
Mahmoud Moravej

Reputation: 9034

Simply write your async codes like this :

public ActionResult ProcessPayment(PaymentModel model)
{

    System.Threading.Tasks.Task.Factory.StartNew(() =>
    {
        //do your payment processing here...
    });

    return view("success blob blob...");
}

Note : anyway your solution has no any fallback strategy. What will you do if you failed through payment process or mail sending process?! If you need a comprehensive solution, use SignalR components (although it is more complex)

Upvotes: 1

Saibal
Saibal

Reputation: 812

Try using an async library like SignalR.

Upvotes: 0

Related Questions