using System.Runtime.InteropServices; namespace Microsoft.Win32.TaskScheduler { /// /// Defines the methods that are called by the Task Scheduler service to manage a COM handler. /// /// /// This interface must be implemented for a task to perform a COM handler action. When the Task Scheduler performs a COM handler action, it creates and activates the handler and calls the methods of this interface as needed. For information on specifying a COM handler action, see the class. /// [ComImport, Guid("839D7762-5121-4009-9234-4F0D19394F04"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), System.Security.SuppressUnmanagedCodeSecurity] public interface ITaskHandler { /// /// Called to start the COM handler. This method must be implemented by the handler. /// /// An IUnkown interface that is used to communicate back with the Task Scheduler. /// The arguments that are required by the handler. These arguments are defined in the property of the COM handler action. void Start([In, MarshalAs(UnmanagedType.IUnknown)] object pHandlerServices, [In, MarshalAs(UnmanagedType.BStr)] string data); /// /// Called to stop the COM handler. This method must be implemented by the handler. /// /// The return code that the Task Schedule will raise as an event when the COM handler action is completed. void Stop([MarshalAs(UnmanagedType.Error)] out int pRetCode); /// /// Called to pause the COM handler. This method is optional and should only be implemented to give the Task Scheduler the ability to pause and restart the handler. /// void Pause(); /// /// Called to resume the COM handler. This method is optional and should only be implemented to give the Task Scheduler the ability to resume the handler. /// void Resume(); } /// /// Provides the methods that are used by COM handlers to notify the Task Scheduler about the status of the handler. /// [ComImport, Guid("EAEC7A8F-27A0-4DDC-8675-14726A01A38A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), System.Security.SuppressUnmanagedCodeSecurity] public interface ITaskHandlerStatus { /// /// Tells the Task Scheduler about the percentage of completion of the COM handler. /// /// A value that indicates the percentage of completion for the COM handler. /// The message that is displayed in the Task Scheduler UI. void UpdateStatus([In] short percentComplete, [In, MarshalAs(UnmanagedType.BStr)] string statusMessage); /// /// Tells the Task Scheduler that the COM handler is completed. /// /// The error code that the Task Scheduler will raise as an event. void TaskCompleted([In, MarshalAs(UnmanagedType.Error)] int taskErrCode); } }