A thread in VB ?? (no ocx!) 
Author Message
 A thread in VB ?? (no ocx!)

Hi guys,

Does anyone know how to create a thread for a certain process.
I wanna make a thread for a class.
Is there an API call for it? (I don't wanna use an ocx or dll....no
offense to others who do use)
Is there a sample that explains "how to"?? Please??????

It seems a hard thing to do in VB (What about Delphi?)

Anyone any ideas?

Greetings from Holland,
R. Evers



Fri, 23 Feb 2001 03:00:00 GMT  
 A thread in VB ?? (no ocx!)
There's one 'multithreading with VB' sample that comes in your VB5.0 CD (it
doen't install with the product). Look for it. The sample uses the magic
under callback functions.

Good Luck

Alberto Gaona
Sinapsis

Quote:

>Hi guys,

>Does anyone know how to create a thread for a certain process.
>I wanna make a thread for a class.
>Is there an API call for it? (I don't wanna use an ocx or dll....no
>offense to others who do use)
>Is there a sample that explains "how to"?? Please??????

>It seems a hard thing to do in VB (What about Delphi?)

>Anyone any ideas?

>Greetings from Holland,
>R. Evers



Fri, 23 Feb 2001 03:00:00 GMT  
 A thread in VB ?? (no ocx!)
[This followup was posted to microsoft.public.vb.general.discussion and a
copy was sent to the cited author.]


Quote:

> Does anyone know how to create a thread for a certain process.
> I wanna make a thread for a class.
> Is there an API call for it? (I don't wanna use an ocx or dll....no
> offense to others who do use)
> Is there a sample that explains "how to"?? Please??????

> It seems a hard thing to do in VB (What about Delphi?)

Since you specifically asked about Delphi, the approach would be:

interace

type
   TMyWorkerThread = class(TThread)
     procedure Execute ;   override ;
   end ;

implementation

  procedure TMyWorkerThread.Execute ;
  begin
    while NOT Terminated do begin
       // Your thread execution code
    end ;
  end ;

Then in your code, you could create multiple instances of this thread:

var
  Thread1       : TMyWorkerThread ;
  Thread2       : TMyWorkerThread ;

procedure CreateThreads ;
begin
  Thread1 := TMyWorkerThread.Create(FALSE) ;
  Thread2 := TMyWorkerThread.Create(TRUE) ;
end ;

That creates two new threads, one which is created in a suspended state
(Thread2) and the other which starts executing immediately (Thread1).

That's it.  In fact it's even easier than that.  You just select "Thread"
from the "File->New" gallery dialog, and the entire framework for your
thread object is created for you, complete with "To Do:" type comments.

Other people will be better qualified than I to provide assistance in
doing it the VB way.

--
Jolyon Smith                          
Neot Software Services Ltd.
"Delivering Quality and Innovation"

http://www.neot.co.uk                    



Sat, 24 Feb 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. OCX OCX OCX OCX OCX OCX

2. vb6 activex ocx components used in multi-threaded client application

3. Multi Threaded Server Apps with mswinsck.ocx

4. THREAD .OCX/.VBX FOR VB4 ON 95/NT

5. Multi-threading using .OCX with Error 424

6. Multi-threading in VB5 using Winsock OCX

7. Multi-threading in VB5 using Winsock OCX

8. Multi-threading in VB5 using Winsock OCX

9. OCX Problem with Multi-threaded Issue

10. Splitter Window OCX for VB, Scrollable Container OCX for VB

11. Safe threading by delivering EVENTS to UI THREAD

12. Threading problem --> threads die

 

 
Powered by phpBB® Forum Software