private static void RunDiscordThread() { var thread = new Thread(async() => { try { DiscordAPI = new DiscordAPI(); while (!_token.IsCancellationRequested) { await Task.Delay(10); } DiscordAPI?.Stop(); } catch (Exception ex) { await LogHelper.LogEx("Discord Thread", ex, LogCat.Discord); DiscordAPI?.Stop(); if (!_token.IsCancellationRequested) { RunDiscordThread(); } } }); thread.Start(); }
private void OnDestroy() { if (Singleton == this) { DiscordAPI.UnregisterEventsHandler(this); DiscordAPI.Stop(); Singleton = null; } }
static void Main(string[] args) { Console.Title = "DiscordUnity"; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Starting up DiscordUnity!"); thread = Thread.CurrentThread; DiscordAPI.Logger = new Logger(); Start(); while (Console.ReadLine() != "exit") { DiscordAPI.Update(); } DiscordAPI.Stop(); Console.ReadKey(); }
public void Dispose() { API.Stop(); }