>I would like to run a form that also has another method or piece of code running independently in the back ground. The form would function as it normally does but it has this other code doing sometime else at the same time. The user would not even know this other piece of code is running and it would continue to execute until the form is released. How can this be done?
Use a timer object. When your form is first instantiated, create a timer object and assign it to a form property so it lives as long as the form. If you want the code to run repeatedly, then set the the timer interval appropriately and have the timer event call your function.
Having said that, you may or may not get the results you want. While the timer will fire independently of your user, the function that it calls may not fire exactly when it should. If your user is running some code that does not have any wait states built into it, then that code will run to its completion. The timer events will build up until a wait state is reached. The same is true if the code the timer event calls does not execute in the interval specified.
If your interval is large enough, this should not present a problem. However, if your interval is very short, then you could have major problems. See a thread started by Mal Shiroma last week about what happened to him and what he did to correct the problem. See Thread
447225.
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao