Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
- {
- AutoResetEvent waitHandle = new AutoResetEvent(false);
- workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
- {
- waitHandle.Set();
- };
- workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
- {
- Console.WriteLine(e.Exception.Message);
- waitHandle.Set();
- };
- WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication1.Workflow1));
- instance.Start();
- waitHandle.WaitOne();
- }
- Console.ReadKey();
- }
- }
- public sealed partial class Workflow1: SequentialWorkflowActivity
- {
- public Workflow1()
- {
- InitializeComponent();
- this.codeActivity1.ExecuteCode += new System.EventHandler(this.codeActivity1_ExecuteCode);
- }
- [DebuggerStepThrough()]
- private void codeActivity1_ExecuteCode(object sender, EventArgs e)
- {
- Console.WriteLine("Throw ApplicationException.");
- throw new ApplicationException();
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- // Here you must free your resources
- // by calling your COM helper Dispose() method
- Console.WriteLine("Object disposed.");
- }
- }
- }
- MyComHelper helper = new MyComHelper();
- helper.DoStuffWithExcel();
- helper.Dispose();
- ...
- MyComHelper helper = new MyComHelper();
- try
- {
- helper.DoStuffWithExcel();
- }
- finally()
- {
- helper.Dispose();
- }
- using(MyComHelper helper = new MyComHelper())
- {
- helper.DoStuffWithExcel();
- }
Add Comment
Please, Sign In to add comment