Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey all
i wanna to make auto function means function run without any event like form_load or button_clilck or ......

and this function run without any affect on the applictaion mean ( user can update database and work on program when the auto funtion run...

any idea if this possible!!!!!
thx for read
Posted
Comments
William Winner 27-Jun-10 20:57pm    
Is this function being started within a form? or are you wanting to start this function when windows loads?

Or is it like wanting to run a backup after so many minutes in the background?
Ashraf ELHakim 27-Jun-10 21:00pm    
thx for ur quick replay
i need the function run in background for example for every 1 min.

1 solution

Well, that's not that hard to do. What you want to do is add a Timer to your form and set it's Interval to 1000 ms (equals 1 sec).

(An article on Timer's can be found here: Pre-beginner's guide to using a timer[^])

Then, when it ticks, you start up a BackgroundWorker and tell it to do what you want. I suggest looking up BackgroundWorker on google, or in the articles here. A good start might be:

BackgroundWorker Threads and Supporting Cancel[^]

or here:
Beginners Guide To Threading In .NET Part 5 of n[^]

The BackgroundWorker is a bit much to get into in a quick answer, but there is a ton of information available on the web.
 
Share this answer
 
Comments
Ashraf ELHakim 27-Jun-10 21:12pm    
thxxxxxxxxxxx for ur answer i will check all of them :)
thx again
Ashraf ELHakim 28-Jun-10 9:17am    
hey eng william
i have issue with backgroundworker
1-i am working on mobile application and the CF dnt support backgroundworker
2- i get the dll. for Backgroundworker from this site
http://www.danielmoth.com/Blog/backgroundworker-for-cf-10.aspx
3- i tried this code
BackgroundWorker bw;
bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.RunWorkerAsync();
void bw_Dowork ()
{
int i=0;
do
{
system.writeline("1");
}while(i==0);
}
this part of code perform the function in bw_Dowork but still not able to run function with it
like if i have button in form how can't click on the button because application perform other operation ?
any idea for this ??!!

i will make sperate question put it here for this and if u have the answer plz and thx for ur effort

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900