PDA

View Full Version : اجرای یک دستور در ساعت مشخص



once4ever
جمعه 31 شهریور 1385, 15:22 عصر
میخوام سر ساعت مشخصی در روز یک تابع رو اجرا کنم
استفاده از تایمر بنظرم اشتباه هست چون نه دقت مورد نظررو داره و هم بارگذاری نامطلوبی انجام میده!
راه دیگه ای هست؟

omid_Ahmadi
جمعه 31 شهریور 1385, 18:59 عصر
Task Scheduler Library For .NET

http://www.codeproject.com/csharp/taskschedulerlibrary.asp

RED-C0DE
شنبه 01 مهر 1385, 01:02 صبح
از طریق فرمان AT هم می تونی این کار رو انجام بدی..

zrahimic
شنبه 01 مهر 1385, 23:55 عصر
سلام
میشه در مورد AT Command بیشتر توضیح بدید؟

ممنون

RED-C0DE
یک شنبه 02 مهر 1385, 22:56 عصر
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.

Amir Oveisi
سه شنبه 04 مهر 1385, 16:43 عصر
میشه از TimerCallBack استفاده کرد

احمد سامعی
چهارشنبه 05 مهر 1385, 01:13 صبح
میشه از TimerCallBack استفاده کرد

می شه کامل توضیح بدین مثلا در یک ساعت مشخص در روز که کاربر مشخص می کنه از یک سری از فایلها که کاربر مشخص می کنه برای مثلا یک ماه Backup گرفته بشه
چطوری از TimerCallBack استفاده کنیم

once4ever
یک شنبه 16 مهر 1385, 21:53 عصر
برنامه من ساده تر از اینه که با Task Scheduler انجام بدم!
یک برنامه هست که همیشه up هست (مثلا بصورت دستی اجرا میکنیم) و فقط میخوام ساعت 10 صبح یه کاری انجام بده. همین.
روش ساده تری برای این هست؟

محمد میرمصطفی
دوشنبه 17 مهر 1385, 06:27 صبح
به نظر من اگه برنامت کوچیکه از Thread.Sleep استفاده کن. یعنی اول اون تکه کد رو توی یه Thread بزار بعد تا زمان موعود، Sleepش کن.

once4ever
دوشنبه 17 مهر 1385, 13:40 عصر
منظورت چیه تا زمان موعود؟ مشکل اون زمان موعود هستش!
مگه اینکه بشه گفت تا ساعت 10 صبح sleep باش!
میشه؟

محمد میرمصطفی
دوشنبه 17 مهر 1385, 14:21 عصر
long remaining;
remaining = DateTime.Parse("10:00").Ticks - DateTime.Now.Ticks;
if(remaining < 0)
remaining = DateTime.Parse("10:00").AddDays(1).Ticks - DateTime.Now.Ticks;
System.Threading.Thread.Sleep(remaining);

once4ever
دوشنبه 17 مهر 1385, 15:03 عصر
همینکارو میتونم با یک تایمر انجام بدم!
فرقش چیه؟