RunningPackage.Stop 方法

定义

停止所选的包。

public:
 void Stop();
public void Stop ();
member this.Stop : unit -> unit
Public Sub Stop ()

示例

以下示例显示当前正在运行的包的属性。 然后,该示例停止所有正在运行的包。

static void Main(string[] args)  
        {  
            Application app = new Application();  
            RunningPackages pkgs = app.GetRunningPackages("yourserver");  

            int pkgsRunning = pkgs.Count;  
            Console.WriteLine("Packages before stop: thas + pkgsRunning);  

            foreach (RunningPackage p in pkgs)  
            {  
                Console.WriteLine("InstanceID: " + p.InstanceID);  
                Console.WriteLine("PackageDescription: " + p.PackageDescription);  
                Console.WriteLine("PackageID: " + p.PackageID);  
                Console.WriteLine("PackageName: " + p.PackageName);  
                Console.WriteLine("UserName: " + p.UserName);  
            }  

            pkgs = app.GetRunningPackages("yourserver");  
            foreach (RunningPackage package in pkgs)  
            {  
                package.Stop();  
            }  

            pkgsRunning = app.GetRunningPackages("yourserver").Count;  
            Console.WriteLine("Packages after stop " + pkgsRunning);  
        }  
Shared  Sub Main(ByVal args() As String)  
            Dim app As Application =  New Application()   
            Dim pkgs As RunningPackages =  app.GetRunningPackages("yourserver")   

            Dim pkgsRunning As Integer =  pkgs.Count   
            Console.WriteLine("Packages before stop: " + pkgsRunning)  

            Dim p As RunningPackage  
            For Each p In pkgs  
                Console.WriteLine("InstanceID: " + p.InstanceID)  
                Console.WriteLine("PackageDescription: " + p.PackageDescription)  
                Console.WriteLine("PackageID: " + p.PackageID)  
                Console.WriteLine("PackageName: " + p.PackageName)  
                Console.WriteLine("UserName: " + p.UserName)  
            Next  

            pkgs = app.GetRunningPackages("yourserver")  
            Dim package As RunningPackage  
            For Each package In pkgs  
                package.Stop()  
            Next  

            pkgsRunning = app.GetRunningPackages("yourserver").Count  
            Console.WriteLine("Packages after stop " + pkgsRunning)  
End Sub  

示例输出:

停止之前的包:1

InstanceID:141f9f2e-920a-4c47-a948-2c0b52a156bd

PackageDescription:

PackageID:aad06953-9847-4ed4-a3b5-fa6092c56e20

PackageName:DTSPackage1

UserName:YOURSERVER\USERID

停止 0 后的包

注解

该方法 Stop 向 Integration Services 服务发出停止请求,但这不会立即停止包。 发出停止请求的时间和包实际停止的时间之间可能存在延迟。

适用于