@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The CreateWaitableTimer API !!!!C# Signature: [DllImport("kernel32.dll")] static extern IntPtr CreateWaitableTimer(IntPtr lpTimerAttributes, bool bManualReset, string lpTimerName); !!!!User-Defined Types: None. !!!!Notes: None. !!!!Tips & Tricks: Please add some! !!!!Sample Code: [DllImport("kernel32.dll")] public static extern IntPtr CreateWaitableTimer(IntPtr lpTimerAttributes, bool bManualReset, string lpTimerName); [DllImport("kernel32.dll")] public static extern bool SetWaitableTimer(IntPtr hTimer, [In] ref long pDueTime, int lPeriod, TimerAPCProc pfnCompletionRoutine, IntPtr lpArgToCompletionRoutine, bool fResume); [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] public static extern Int32 WaitForSingleObject(IntPtr handle, int milliseconds); public static uint INFINITE = 0xFFFFFFFF; The main code is : private IntPtr handle; private void shutdownToolStripMenuItem_Click(object sender, EventArgs e) { DateTime dt = DateTime.Now; dt = dt.AddSeconds(30.0); long duetime = dt.ToFileTime(); handle = Win32.PowerManagement.CreateWaitableTimer(IntPtr.Zero, true, ""); Win32.PowerManagement.SetWaitableTimer(handle, ref duetime, 0, null, IntPtr.Zero, true); Thread t = new Thread(new ThreadStart(this.NewThread)); t.Start(); } private void NewThread() { int ret = Win32.PowerManagement.WaitForSingleObject(handle, (int)Win32.PowerManagement.INFINITE); MessageBox.Show("Wait object"); // ret = 0x00000000L here } !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: CreateWaitableTimer@msdn on MSDN
Edit kernel32.createwa...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.