Back to Index

 

 

Job Component

     RunJobThreaded method

 

RunJobThreaded()

     Returns:  None

 

The RunJobThreaded method will run the job process on a new thread and continue on with your code immediately.  To know when your job is done, simply add a handler to the JobCompleted event, or you can check the status in timer event by calling the GetJobStatus method.

Example:

[Visual Basic .NET]  

Imports VisualIntegrationStudio.SharedDomain

 

Public Class Form1

    Inherits System.Windows.Forms.Form

 

    Private myExportBudgetJob As ExportBudget

 

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        myExportBudgetJob = New ExportBudget()

        myExportBudgetJob.JobPaths.JobStatusFileName = "ExportJobStatus.xml"

 

        AddHandler myExportBudgetJob.JobCompleted, AddressOf JobIsDone

   End Sub

 

   Private Sub btnRunJob_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRunJob.Click

        myExportBudgetJob.RunJobThreaded()

   End Sub

 

   Private Sub JobIsDone(ByVal obj As Object)

 

        If Not (obj Is Nothing) Then

            MsgBox("Job is done, Status: " + CType(obj, ExportBudget.ReturnStatusTypes).ToString)

        Else

            MsgBox("Job is done")

        End If

 

   End Sub

 

End Class

 

[C#]

 

using System;

 

using System.Drawing;

 

using System.Collections;

 

using System.ComponentModel;

 

using System.Windows.Forms;

 

using System.Data;

using VisualIntegrationStudio.SharedDomain;

 

 

 

namespace MyApplicationCs

 

{

 

       public class Form1 : System.Windows.Forms.Form

 

       {

 

             private System.Windows.Forms.Button btnRunJob;

 

             private System.ComponentModel.Container components = null;

 

 

             private ExportBudget myExportBudgetJob;

 

 

 

             public Form1()

 

             {

 

                   InitializeComponent();

 

             }

 

 

 

             protected override void Dispose( bool disposing )

 

             {

 

                    if( disposing )

 

                    {

 

                          if (components != null)

 

                         {

 

                                components.Dispose();

 

                         }

 

                    }

 

                    base.Dispose( disposing );

 

            }

 

 

 

            [STAThread]

 

            static void Main()

 

            {

 

                 Application.Run(new Form1());

 

            }

 

 

 

            private void Form1_Load(object sender, System.EventArgs e)

 

            {

                   myExportBudgetJob = new ExportBudget();

                   myExportBudgetJob.JobPaths.JobStatusFileName = "ExportJobStatus.xml";

 

 

                   myExportBudgetJob.JobCompleted += new ExportBudget.JobCompletedEventHandler(JobIsDone);

 

            }

 

 

 

            private void btnRunJob_Click(object sender, System.EventArgs e)

 

            {

                  myExportBudgetJob.RunJobThreaded();

 

            }

 

 

            private void JobIsDone(object obj, System.EventArgs e)

            {

                  MessageBox.Show("Job is done, Status: " + ((ExportBudget.ReturnStatusTypes)obj).ToString());

            }

 

 

 

       }

 

}

 

 

 

 

 

 


© 2003 - 2007 Relational Solutions, Inc. - All rights reserved