ServiceController.Refresh メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ServiceController.Refresh メソッドの意味・解説 

ServiceController.Refresh メソッド

すべてのプロパティ値を現在の値に設定して更新します

名前空間: System.ServiceProcess
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

解説解説

Refresh は ServiceController プロパティ既定値戻しますまた、このメソッドは ServicesDependedOn および DependentServices プロパティnull 参照 (Visual Basic では Nothing) に設定します

使用例使用例

ServiceController クラス使用してTelnet サービス現在のステータス確認する例を次に示しますサービス停止している場合、このコードサービス開始しますサービス実行中である場合は、そのサービス停止します

' Toggle the Telnet service - 
' If it is started (running, paused, etc), stop the service.
' If it is stopped, start the service.
Dim sc As New ServiceController("Telnet")
Console.WriteLine("The Telnet service status is currently set
 to {0}", sc.Status)

If sc.Status.Equals(ServiceControllerStatus.Stopped) Or
 sc.Status.Equals(ServiceControllerStatus.StopPending) Then
   ' Start the service if the current status is stopped.
   Console.WriteLine("Starting the Telnet service...")
   sc.Start()
Else
   ' Stop the service if its status is not set to "Stopped".
   Console.WriteLine("Stopping the Telnet service...")
   sc.Stop()
End If

' Refresh and display the current service status.
sc.Refresh()
Console.WriteLine("The Telnet service status is now set to {0}.",
 sc.Status)

// Toggle the Telnet service - 
// If it is started (running, paused, etc), stop the service.
// If it is stopped, start the service.
ServiceController sc = new ServiceController("Telnet");
Console.WriteLine("The Telnet service status is currently set
 to {0}", 
                  sc.Status.ToString());

if  ((sc.Status.Equals(ServiceControllerStatus.Stopped)) ||
     (sc.Status.Equals(ServiceControllerStatus.StopPending)))
{
   // Start the service if the current status is stopped.

   Console.WriteLine("Starting the Telnet service...");
   sc.Start();
}  
else
{
   // Stop the service if its status is not set to "Stopped".

   Console.WriteLine("Stopping the Telnet service...");
   sc.Stop();
}  

// Refresh and display the current service status.
sc.Refresh();
Console.WriteLine("The Telnet service status is now set to
 {0}.", 
                   sc.Status.ToString());

// Toggle the Telnet service - 
// If it is started (running, paused, etc), stop the service.
// If it is stopped, start the service.
ServiceController^ sc = gcnew ServiceController(  "Telnet" );
if ( sc )
{
   Console::WriteLine(  "The Telnet service status is currently set
 to {0}", sc->Status );
   if ( (sc->Status == (ServiceControllerStatus::Stopped) )
 || (sc->Status == (ServiceControllerStatus::StopPending) ) )
   {
      // Start the service if the current status is stopped.
      Console::WriteLine(  "Starting the Telnet service..." );
      sc->Start();
   }
   else
   {
      // Stop the service if its status is not set to "Stopped".
      Console::WriteLine(  "Stopping the Telnet service..." );
      sc->Stop();
   }

   // Refresh and display the current service status.
   sc->Refresh();
   Console::WriteLine(  "The Telnet service status is now set
 to {0}.", sc->Status );
// Toggle the Telnet service - 
// If it is started (running, paused, etc), stop the service.
// If it is stopped, start the service.
ServiceController sc = new ServiceController("Telnet");
Console.WriteLine("The Telnet service status is currently set
 to {0}",
    sc.get_Status().ToString());

if (sc.get_Status().Equals(ServiceControllerStatus.Stopped) ||
 
    sc.get_Status().Equals(ServiceControllerStatus.StopPending)) {
    // Start the service if the current status is stopped.
    Console.WriteLine("Starting the Telnet service...");
    sc.Start();
}
else {
    // Stop the service if its status is not set to "Stopped".
    Console.WriteLine("Stopping the Telnet service...");
    sc.Stop();
}
// Refresh and display the current service status.
sc.Refresh();
Console.WriteLine("The Telnet service status is now set to
 {0}.", 
    sc.get_Status().ToString());
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からServiceController.Refresh メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からServiceController.Refresh メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からServiceController.Refresh メソッドを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ServiceController.Refresh メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ServiceController.Refresh メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS