Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multithreaded COM
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
00839972
Message ID:
00840065
Vues:
24
The problem is that when you create a new thread in .Net it's an MTA thread, not a single threaded apartment that VFP requires to simulate multi-threading...

I've set up a quick test and changed my code to this:

private void button1_Click(object sender, System.EventArgs e)
{
Thread t = new Thread(new ThreadStart(threadrun));
t.Name = "#1";
t.ApartmentState = ApartmentState.STA;
t.Start();

Thread t2 = new Thread(new ThreadStart(threadrun));
t2.Name = "#2";
t2.ApartmentState = ApartmentState.STA;
t2.Start();
}
public void threadrun()
{
this.listBox1.Items.Insert(0,"Thread Started. " + Thread.CurrentThread.Name + " " + DateTime.Now.ToString());
aspdemos.ASPToolsClass x = new aspdemos.ASPToolsClass();
x.SlowHit(10);
this.listBox1.Items.Insert(0,"Thread Complete. " + Thread.CurrentThread.Name + " " + DateTime.Now.ToString());
}

which works. When I run this both requests return simultaneously (I have a static wait in SlowHit()).

+++ Rick ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform