Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / May 2004

Tip: Looking for answers? Try searching our database.

multithreading in COM+ using C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kazi - 24 Mar 2004 13:18 GMT
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%3A%2F%2Fmsdn.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...
AlexS - 15 May 2004 22:28 GMT
Hi, kazi

Check ApartmentState of Thread class.

HTH
Alex

> Hi
>     I'm programming a application use the COM+, MSMQ, SQL server. I want to
[quoted text clipped - 7 lines]
> how to the change the attribute in the C#.
>     Threading Model Attribute (COM+ (Component Services)) :

http://search.microsoft.com/search/info.aspx?u=http%3A%2F%2Fmsdn.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+
[quoted text clipped - 37 lines]
>
> Thanks in advance...

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.