K
kazi
Hi
I'm programming a application use the COM+, MSMQ, SQL server. I want to
use one thread reading the data from the SQL server, and then put then to a
System.Collections.Queue, use another thread get the data from the Queue and
then Send them to the MSMQ.
Now i meet a problem that the COM+ run in the STA model only allow one
method running in one time.How can i change the COM+ to MTA model in C#
language?
I have already read the COM+ SDK documents in the MSDN, but i don't know
how to the change the attribute in the C#.
Threading Model Attribute (COM+ (Component Services)) :
http://search.microsoft.com/search/info.aspx?u=http://msdn.microsoft.c
om%2Flibrary%2Fen-us%2Fcossdk%2Fhtm%2Fpgcontexts_0pk5.asp&n=0&na=&c=0&View=m
sdn&st=a&qu=com%2b+Threading&c=0&s=1
COM Threading and Application Architecture in COM+ Applications (COM+
Technical Articles) :
http://msdn.microsoft.com/library/en-us/dncomser/html/comthread.asp
The following is the simple code of my program.
//COM+
public class ComPlus : System.EnterpriseServices.ServicedComponent
{
private System.Collections.Queue Q;
public ComPlus() {}
public void MethodOne() { /* Read data from SQL server, Put them to the
Q */}
public void MethodTwo() { /* Read data from Q, Send them to the MSMQ */}
}
//Console Application (or Windows Services)
public class MainApp
{
public static void Main()
{
ComPlus com = new ComPlus();
System.Threading.Thread threadOne = new Thread(new
ThreadStart(com.MethodOne));
System.Threading.Thread threadTwo = new Thread(new
ThreadStart(com.MethodTwo));
threadOne.Start(); //MethodOne can run in normally.
threadTwo.Start(); //But the MethodTwo can't run when the others
running.
//I want to improve the performance of the
application,
//So I want them to run in one time;
threadOne.Join();
threadTwo.Join();
}
}
Thanks in advance...
I'm programming a application use the COM+, MSMQ, SQL server. I want to
use one thread reading the data from the SQL server, and then put then to a
System.Collections.Queue, use another thread get the data from the Queue and
then Send them to the MSMQ.
Now i meet a problem that the COM+ run in the STA model only allow one
method running in one time.How can i change the COM+ to MTA model in C#
language?
I have already read the COM+ SDK documents in the MSDN, but i don't know
how to the change the attribute in the C#.
Threading Model Attribute (COM+ (Component Services)) :
http://search.microsoft.com/search/info.aspx?u=http://msdn.microsoft.c
om%2Flibrary%2Fen-us%2Fcossdk%2Fhtm%2Fpgcontexts_0pk5.asp&n=0&na=&c=0&View=m
sdn&st=a&qu=com%2b+Threading&c=0&s=1
COM Threading and Application Architecture in COM+ Applications (COM+
Technical Articles) :
http://msdn.microsoft.com/library/en-us/dncomser/html/comthread.asp
The following is the simple code of my program.
//COM+
public class ComPlus : System.EnterpriseServices.ServicedComponent
{
private System.Collections.Queue Q;
public ComPlus() {}
public void MethodOne() { /* Read data from SQL server, Put them to the
Q */}
public void MethodTwo() { /* Read data from Q, Send them to the MSMQ */}
}
//Console Application (or Windows Services)
public class MainApp
{
public static void Main()
{
ComPlus com = new ComPlus();
System.Threading.Thread threadOne = new Thread(new
ThreadStart(com.MethodOne));
System.Threading.Thread threadTwo = new Thread(new
ThreadStart(com.MethodTwo));
threadOne.Start(); //MethodOne can run in normally.
threadTwo.Start(); //But the MethodTwo can't run when the others
running.
//I want to improve the performance of the
application,
//So I want them to run in one time;
threadOne.Join();
threadTwo.Join();
}
}
Thanks in advance...