メインメニューを開く

差分

Xamarin.Macでアプリ自身を再起動する

241 バイト追加, 2020年3月5日 (木) 03:17
この状態でRestartRequestedフラグにtrueを設定してアプリを終了すれば再起動になる。
<source lang="csharp">
public override void WillTerminate [Register(NSNotification notification"AppDelegate")]public class AppDelegate : NSApplicationDelegate
{
if // 〜〜〜 中略 〜〜〜  // 再起動フラグ public bool RestartRequested = false;  // アプリ終了時に呼ばれる public override void WillTerminate (RestartRequestedNSNotification notification)
{
// 再起動フラグ if (RestartRequested) { // 自分自身を起動 NSWorkspace.SharedWorkspace.LaunchApp ( NSBundle.MainBundle.BundleIdentifier, NSWorkspaceLaunchOptions.NewInstance | NSWorkspaceLaunchOptions.Async, NSAppleEventDescriptor.NullDescriptor, IntPtr.Zero); }
}
}
 
</source>
[[category: Xamarin.Mac]]