0

Currently i have a web application and a wins form application in my server. Basically, the web application will receive request from user and this request will be send to the wins form application to proceed (wins form need about 1 minute to complete a request).

Let say 2 users send a request at the same time via web application, I need to develop a queue job to maintain the request in sequence.

1) User A make a request > request will be store into a queue job

2) User B make a request > request will be store into a queue job

3) The queue job will send the first request to the wins form. Once first request is complete, then will follow by the second request

So my question is, this queue job should be develop inside the web application? Or it should be develop in a stand alone wins form?

Any example code for create a queue job in ASP.NET?

Or anyone can suggest a better solution?

4

3 に答える 3

0
using System.Collections.Generic;

Queue<task> Q = new Queue<task>();


public void Proccess_Request(string info)
{
    task t = new task();
    t.INFO = info;
    Q.Enqueue(task);
}

public void DoWork()
{
    //
    while (Q.Count > 0)
    {
        task t = Q.Dequeue();            
        //Process task t
    }

}


public class task
{
    public string INFO { get; set; }
    // Whatever task properties you need
}

フォーム データを受け取り、メソッドに渡すサービスを構築する必要がありますProcess_Request。また、メソッドを x 分ごとに 1 回呼び出すDoWorkか、メソッドをリッスンして起動させる必要がありProcess_Requestます。

于 2013-10-09T03:01:07.233 に答える
0

または、MSMQ を使用してそのようにすることもできます。ASP.NET サイトはキューにメッセージを送信し、winforms アプリ (またはサービス) はキューにバインドされているため、メッセージがキューに入ると、それを取得して処理し、メッセージがなくなるまで実行させます。待ち行列。

于 2013-10-09T03:10:10.700 に答える