Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multithreaded COM
Message
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00839972
Message ID:
00840065
Views:
23
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?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform