rodfiuza
10-05-2001, 07:46 PM
Hi, i'm in personal project that i think would be better if use threads. I already know that i can use it with api calls. I just wondering what is the best way to do it without taking the system down ( which already happened...). Thanks for helping!
if you want to hit the stars,shoot to the sky.
Thinker
10-05-2001, 08:04 PM
There is no best way with VB. There is only one way and it is incredibly
complex. CL is currently working on an example project that should make
it much easier to do and understand. In the mean-time, ask yourself and
the forum what advantage you would hope to get out of using multiple
threads. If you only have a single processor, multiple threads can only
help if you have some processes that could block other ones. In these
cases, most of the time you can get by with an ActiveX EXE server.
I think therefore I am... sometimes right. images/icons/wink.gif
usetheforce2
10-05-2001, 08:25 PM
hey,
hmmm, well threads, i regards to application threads i suppose you'de have to consider the priority level of the thread to avoid "Taking the system down". Since a thread is a unit of code in an application that is scheduled for processing, and based on its priority level the cpu decides when to process such threads. You may be inadvertently forcing the cpu to process you thread "uninterupted" causing your system to crash. Also, threads resided in a context refered too as a Process. Its the process that can crash a system rather than a thread. Threads are easially exchanged with other threads for processing, and the cpu can transfer between threads with very little overhead.however, keep in mind that all application threads reside in a process and share the same memory and system resources. So switching between processes (groups of application threads) involves a great deal of overhead, including copying large amount of data from memory to disk. So if you're forcing a process down the cpu throat before it has time to deal with the other process then you can run into trouble...
I'm not really familiar with any "Thread" api calls, aside from SetThreadLocale and GetThreadLocale, which i don't think they could cause your system to crash.
I realize i haven't really provided a solution for your problem, rather i just rambled on about "Threads", but maybe it lends some insight on what may be causing your problems.
Good luck...
"The crows seem to be calling his name, thought Caw." - Jack Handy
rodfiuza
10-05-2001, 08:42 PM
One of the situations is when i'm playng a wav file and it seens to stop all the process until it is over.Well, in fact there's a lot of situations where i found that i could let the programs do other small tasks while other heavy computations where running in the background. But i think i can wait for a tip from one of the gurus of this site :) Thanks for helping!
if you want to hit the stars,shoot to the sky.
Volte
10-05-2001, 08:51 PM
well, the wav playing thing is simple. It needs to be played in Asyncronous mode, using the constant
Const SND_ASYNC = &H1
and the line
sndPlaySound "sound.wav", SND_ASYNC Or SND_NODEFAULT