本文整理汇总了C#中Bot.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Bot.Run方法的具体用法?C# Bot.Run怎么用?C# Bot.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bot
的用法示例。
在下文中一共展示了Bot.Run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
MemoryReaderFactory memoryReaderFactory = new MemoryReaderFactory();
Bot bot = new Bot();
bot.GameStage = new GameStageEmulatorNotLaunched(bot, memoryReaderFactory);
while (!bot.ShutdownRequested) bot.Run();
}
示例2: Main
private static void Main(string[] args)
{
using (var bot = new Bot())
{
bot.Run();
}
}
示例3: Main
/// <summary>
/// Main.
/// </summary>
/// <param name="args">Args from the command line.</param>
static void Main(string[] args)
{
try
{
// disallow ability to close this console window while we're running
DisableConsoleExit();
// set console properties and display header
System.Console.Title = "Oberon - Deviant Art Chat Bot";
System.Console.WindowHeight = System.Console.LargestWindowHeight / 2;
System.Console.Clear();
System.Console.WriteLine(new string('*', System.Console.WindowWidth - 1));
System.Console.WriteLine();
System.Console.WriteLine(" Oberon - Deviant Art Chat Bot");
System.Console.WriteLine();
System.Console.WriteLine(new string('*', System.Console.WindowWidth - 1));
System.Console.WriteLine(" In order to close this program type 'exit' or 'quit'.");
System.Console.WriteLine(" See http://oberon.thehomeofjon.net for the latest bot info.");
System.Console.WriteLine(new string('*', System.Console.WindowWidth - 1));
// ensure we only have one instance running
if (IsPriorProcessRunning())
{
System.Console.WriteLine("HEY! Only one instance of the application can be started.");
System.Console.WriteLine("Shutting down in 10 seconds.");
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10.0));
return;
}
// create background worker to run the bot
var botWorker = new BackgroundWorker();
botWorker.WorkerReportsProgress = false;
botWorker.WorkerSupportsCancellation = false;
botWorker.DoWork += (sender, a) =>
{
// create our IoC container
IUnityContainer globalContainer = new UnityContainer();
// setup the default bot dependencies
Bot.Setup(globalContainer);
// get a reference to the bot
Bot = globalContainer.Resolve<Bot>();
// check for updates
Bot.NotifyUserOfBotUpdates();
// run the bot
Bot.Run();
// keep worker running until bot shuts down
while (Bot.IsAlive) ;
};
// start the background worker
botWorker.RunWorkerAsync();
// listen for user input from the console
while (true)
{
string input = ReadFromConsole();
if (!string.IsNullOrEmpty(input))
{
// if we receive the command, then shutdown
if (input.ToUpperInvariant() == "EXIT" ||
input.ToUpperInvariant() == "QUIT")
{
Bot.Console.Notice("Initiating shutdown.");
// send the shutdown command
Bot.Shutdown();
// since we're the main thread, don't exit until
// the bot itself shuts down so we don't have an
// orphaned thread gets left or gets terminated too
// early.
while (Bot.IsAlive) ;
break;
}
}
// check and make sure bot isn't dead
if (Bot != null && Bot.IsAlive == false)
break;
}
// display exit message
System.Console.WriteLine(new string('*', System.Console.WindowWidth - 1));
System.Console.WriteLine("Console closing.");
}
catch (Exception ex)
{
// dump exception to log file
try
//.........这里部分代码省略.........