本文介绍了[ASK]-关于线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,专家们,我想问问您有关线程的问题.我在执行绪时遇到问题,我的网路服务包含3种方法,例如:ReceiveDataStatic,ReceiveDataInvestor和ReceiveDataValidator.

当客户端要使用此服务时,他们可以同时使用这些方法.我对我的应用程序的性能感到困惑,所以我做了一些类似这样的线程::〜


Hi experts, i wanna ask u about thread. i''ve a problem in threading, i''ve had webservice that contain 3 method, such as : ReceiveDataStatic, ReceiveDataInvestor, and ReceiveDataValidator.

When the client want to use this service, they can use these methods at the same time. I''ve confused about the performance of my application,so i''ve made some thread like this : :~


// This is the web method
[WebMethod]
public void ReceiveDataStatic(object obj)
{
  ClassMessage o = new ClassMessage();
  o.ProcessMessage(obj); // Call ProcessMessage method in other class
}

[WebMethod]
public void ReceiveDataInvestor(object obj)
{
   ClassMessage o = new ClassMessage();
   o.ProcessMessage(obj);
}

[WebMethod]
public void ValidatorDataInvestor(object obj)
{
   ClassMessage o = new ClassMessage();
   o.ProcessMessage(obj);
}









//Class ClassMessage.cs
public void ProcessMessage(object obj)
{
  switch (type)
  {
    case "Data Static":
      oThread1 = new Thread(ParseDataStatic);
      oThread1.Start(obj);
      break;
    case "Data Investor":
      oThread2 = new Thread(ParseDataInvestor);
      oThread2.Start(obj);
      break;
    case "Inventory Validation":
      oThread3 = new Thread(ParseDataInvValidation);
      oThread3.Start(obj);
      break;
  }


}

嗯..我想,这是我的把戏..:~~我们知道,要处理的事情是基于FIFO(先进先出)的.因此,如果一个客户端要首先使用"ReceiveDataStatic",则将尽早处理此方法公开的消息.以及,如果其他客户端使用其他方法,mmm ..我们假设他们同时使用"ReceiveDataInvestor"方法呢?这个线程可以同时运行吗(我们必须记住关于FIFO)? (我的意思是2个线程可以同时运行.)

有什么建议或解决此问题的最佳方法吗?请帮助我..:confused:


}

Hhhmmm.. i think, this my trick.. :~ As we know, to process something is based on FIFO (First In, First Out). So, if one client want to use "ReceiveDataStatic" first, the message that is reveived by this method will be processed as early as possible. And how, if other client using other method, mmm.. we assume they use "ReceiveDataInvestor" method at the same time?? Is this thread can run at the same time (we must remember about FIFO)?? (i mean that 2 threads can run simultaneously.)

Is there any suggestion or the best way for this problem..?? help me please.. :confused:

推荐答案



这篇关于[ASK]-关于线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 09:45