Last active
June 14, 2017 01:09
-
-
Save redbaty/b432253a6402029a1b4396e08e4d9b40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Drawing; | |
using System.Threading.Tasks; | |
using Colorful; | |
using Console = System.Console; | |
namespace Demo | |
{ | |
class Program | |
{ | |
private static bool _isRunning = true; | |
static void Main(string[] args) | |
{ | |
Task.Factory.StartNew(() => | |
{ | |
while (true) | |
{ | |
if (!_isRunning) break; | |
WriteRandom(); | |
} | |
}); | |
Task.Factory.StartNew(() => | |
{ | |
while (true) | |
{ | |
if (!_isRunning) break; | |
WriteRandom(); | |
} | |
}); | |
Task.Factory.StartNew(() => | |
{ | |
while (true) | |
{ | |
if (!_isRunning) break; | |
WriteRandom(); | |
} | |
}); | |
Console.ReadKey(); | |
_isRunning = false; | |
Console.ReadKey(); | |
} | |
static void WriteRandom() | |
{ | |
var dream = "a dream of {0} and {1} and {2} and {3} and {4} and {5} and {6} and {7} and {8} and {9}..."; | |
Formatter[] fruits = | |
{ | |
new Formatter("bananas", Color.LightGoldenrodYellow), | |
new Formatter("strawberries", Color.Pink), | |
new Formatter("mangoes", Color.PeachPuff), | |
new Formatter("pineapples", Color.Yellow), | |
new Formatter("cherries", Color.Red), | |
new Formatter("oranges", Color.Orange), | |
new Formatter("apples", Color.LawnGreen), | |
new Formatter("peaches", Color.MistyRose), | |
new Formatter("plums", Color.Indigo), | |
new Formatter("melons", Color.LightGreen), | |
}; | |
Colorful.Console.WriteLineFormatted(dream, Color.Gray, fruits); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment