Example #1
0
        // The working thread.
        private void Run()
        {
            try
            {
                // Try to connect to the proxy.
                ProxyConnection = new Socks5ProxyClient(configuration.GetProxyAddress(), configuration.GetProxyPort(), "", "");

                // Try to connect to the pool
                PoolConnection = ProxyConnection.CreateConnection(configuration.GetPoolAddress(), configuration.GetPoolPort());

                // Write to the console that the pool has beenc onnected.
                Program.ConsoleWriteLineWithColor(ConsoleColor.Green, "Successfully connected to your pool!");
                Program.ConsoleWriteLineWithColor(ConsoleColor.Green, "The new miner is ready to mine!");
            }
            catch (Exception exception)
            {
                Program.ConsoleWriteLineWithColor(ConsoleColor.Red, "Failed to establish a connection to the pool, the miner will be disconnected.");
                Console.WriteLine(exception.ToString());
            }

            // Main routine that sleeps and exchanges data to prevent high cpu usage.
            while (MinerConnection.Connected && PoolConnection.Connected)
            {
                // Small sleep so we don't use 100% of the cpu
                Thread.Sleep(10);

                // Exchange the data.
                ExchangeData();
            }

            // See you, space cowboy.
            wantsToBeDisposed = true;
        }