Share via


SPRunningJob class

執行的工作物件會建立每個執行個體之工作的執行,其中每個伺服器的速率。

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPRunningJob

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public NotInheritable Class SPRunningJob
'用途
Dim instance As SPRunningJob
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public sealed class SPRunningJob

備註

如果使用中伺服器陣列中的至少一部伺服器上執行的工作,標示為 [作用中

成功完成一次性工作刪除的資料表執行工作。也會刪除其工作定義。

Examples

下列程式碼範例會逐一顯示目前執行每個服務的每個工作的相關資訊的SharePoint Foundation伺服器陣列上的服務。所有以程式設計方式進行互動是屬性 ; SPRunningJob物件,有可允許與SPRunningJob物件的特定執行個體互動執行者SPRunningJobCollection物件中的方法。

[C#]

SPFarm farm = SPFarm.Local.Farm;
SPServiceCollection services = SPFarm.Local.Services;
int rand_job;
Guid jobdefid;
SPRunningJob rj;
string servername;
string svc_name = string.Empty;
 foreach (SPService service in services) {
  SPRunningJobCollection runningJobs = service.RunningJobs;
  if (runningJobs.Count > 0) {
    if (svc_name == string.Empty) {
      svc_name = service.Name;
    }
    Console.WriteLine("****Job Collection Count is     " + runningJobs.Count);
    Console.WriteLine("****Job Collection Parent is    " + runningJobs.Parent);
    Console.WriteLine("****Job Collection Service is   " + runningJobs.Service);
    Console.WriteLine("****Job Collection Web App is   " + runningJobs.WebApplication);
    // For the GetInstance method, save off job information at random
    rand_job = runningJobs.Count / 2;
    Console.WriteLine("****Collection member " + rand_job + " is " + runningJobs[rand_job].JobDefinition);
    jobdefid = runningJobs[rand_job].JobDefinitionId;
    servername = runningJobs[rand_job].ServerName;
  }
  else {
    jobdefid = Guid.Empty;
    servername = null;
  }
  foreach (SPRunningJob runningJob in runningJobs) {
    Console.WriteLine("****Job Definition is   " + runningJob.JobDefinition);
    Console.WriteLine("****Job Id is           " + runningJob.JobDefinitionId);
    Console.WriteLine("****Job Title is        " + runningJob.JobDefinitionTitle);
    Console.WriteLine("****Parent is           " + runningJob.Parent);
    Console.WriteLine("****Percentage Done is  " + runningJob.PercentageDone);
    Console.WriteLine("****Server Name is      " + runningJob.ServerName);
    Console.WriteLine("****Service Id is       " + runningJob.ServiceId);
    Console.WriteLine("****Start Time is       " + runningJob.StartTime);
    Console.WriteLine("****Status is           " + runningJob.Status);
    Console.WriteLine("****Web App Id is       " + runningJob.WebApplicationId);
    Console.WriteLine("****");
  }
  if (jobdefid != Guid.Empty) {
    // random jobdef from collection 
    // getinstance method
    rj = runningJobs.GetInstance(jobdefid, servername);
    Console.WriteLine("*@@* Job Definition is   " + rj.JobDefinition);
    Console.WriteLine("*@@* Job Id is           " + rj.JobDefinitionId);
    Console.WriteLine("*@@* Job Title is        " + rj.JobDefinitionTitle);
  }
}

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

請參閱

參照

SPRunningJob members

Microsoft.SharePoint.Administration namespace

其他資源

建立 Windows SharePoint Services 3.0 中的自訂的計時器工作