Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multithreaded COM
Message
 
To
17/10/2003 23:47:23
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00839972
Message ID:
00839995
Views:
16
Your C# client needs to be truly multithreaded to take advantage of VFP's multithreading. I think you have to program for this specifically. Here's a good link: http://www.developer.com/net/asp/article.php/2202491 - Multithreading in .NET applications. Here's an example of a C++ client calling multiple VFP threads simultaneously: http://www.dotcomsolution.com/dna08.htm (at the end of the article).
Yes, .vfp. mtdlls are really multithreaded. The terminology is kind of confusing -VFP and VB support Apartment Threading (Single Threaded Apartments) while C++, C#, VB.NEt support Free Threading (Multi Threaded Apartments). They both are truly multithreaded but accomplish the same thing in different ways. Here's a good link: http://www.developer.com/net/asp/article.php/2202491 - Multithreading in .NET applications.
>Hi all,
>I want to create a VFP Com and call its method on 2 different threads. I am using C# and the threads create just as I would expect, but when I call my fox function from the second thread, it still waits for the first one to finish.
>I built the dll using the Multi-threaded COM Server option.
>I have read alot of stuff about how VFP is Multi Apartment not truly Multithreaded, but I'm not sure if that is what is causing the problem I'm having.
>Any help, or advice would be much appreciated.
>
>TIA
>Clayton Hall --
>
>C# Code
>
>private void button1_Click(object sender, System.EventArgs e)
>{
>	Thread t = new Thread(new ThreadStart(threadrun));
>	t.Start();
>	
>	Thread t2 = new Thread(new ThreadStart(threadrun));
>	t2.Start();
>}
>
>public void threadrun()
>{
>	vfpmtcom.MtSimple x = new vfpmtcom.MtSimpleClass();
>	x.DoWhile();
>}
>
>
>VFP Code
>
>*\\Create Table c:\mtSimple.dbf (logtext c(50))
>
>Define CLASS MtSimple As Relation OLEPublic
>
>Function Init()
>	USE c:\mtSimple.dbf Shared
>EndFunc
>
>Function DoWhile()
>	lnLastTime = Datetime()
>	lnCounter = 0
>	
>	DO While lnCounter < 10
>		If Datetime() <> lnLastTime
>			lnCounter = lnCounter + 1
>			Insert Into mtSimple (logtext) Values ("Count:"+Transform(lnCounter))
>			lnLastTime = Datetime()
>		Endif
>	Enddo
>EndFunc
>
>EndDefine
>
>Here were my results...
>I want the numbers to be jumbled.
>
>Count:1
>Count:2
>Count:3
>Count:4
>Count:5
>Count:6
>Count:7
>Count:8
>Count:9
>Count:10
>Count:1
>Count:2
>Count:3
>Count:4
>Count:5
>Count:6
>Count:7
>Count:8
>Count:9
>Count:10
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform