Notify() публичный Метод

public Notify ( StockTick tick ) : void
tick StockTick
Результат void
Пример #1
0
        private static void Main(string[] args)
        {
            var shoppy = new Shoppy();
            shoppy.TestShoppy();
            return;
            ;

            var stockTicker = new StockTicker();
            var stockListner = new RxStockMonitor(stockTicker);
            ThreadPool.QueueUserWorkItem((_)=>stockTicker.Notify(new StockTick() { Price = 100, QuoteSymbol = "MSFT" }));
            ThreadPool.QueueUserWorkItem((_)=>stockTicker.Notify(new StockTick() { Price = 150, QuoteSymbol = "INTC" }));
            ThreadPool.QueueUserWorkItem((_)=>stockTicker.Notify(new StockTick() { Price = 170, QuoteSymbol = "MSFT" }));
            ThreadPool.QueueUserWorkItem((_)=>stockTicker.Notify(new StockTick() { Price = 195.5M, QuoteSymbol = "MSFT" }));

            while (true)
            {
                Console.Write("enter symbol: ");
                var symbol = Console.ReadLine();
                if (symbol.ToLower() == "x")
                {
                    break;
                }
                Console.WriteLine("enter value: ");
                var val = decimal.Parse(Console.ReadLine());
                for (int i = 0; i < 30; i++)
                {
                    int i1 = i;
                    Task.Run(() => stockTicker.Notify(new StockTick() { Price = val, QuoteSymbol = symbol + i1 }));
                }
            }

            Console.WriteLine("Bye Bye");
        }
Пример #2
0
 private static void TestConcurrentTicks(StockTicker stockTicker)
 {
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick() {Price = 100, QuoteSymbol = "MSFT"}));
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick() {Price = 150, QuoteSymbol = "INTC"}));
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick() {Price = 170, QuoteSymbol = "MSFT"}));
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick() {Price = 195.5M, QuoteSymbol = "MSFT"}));
 }
Пример #3
0
        private static void Main(string[] args)
        {
            var shoppy = new Shoppy();

            shoppy.TestShoppy();
            return;

            ;

            var stockTicker  = new StockTicker();
            var stockListner = new RxStockMonitor(stockTicker);

            ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
            {
                Price = 100, QuoteSymbol = "MSFT"
            }));
            ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
            {
                Price = 150, QuoteSymbol = "INTC"
            }));
            ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
            {
                Price = 170, QuoteSymbol = "MSFT"
            }));
            ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
            {
                Price = 195.5M, QuoteSymbol = "MSFT"
            }));


            while (true)
            {
                Console.Write("enter symbol: ");
                var symbol = Console.ReadLine();
                if (symbol.ToLower() == "x")
                {
                    break;
                }
                Console.WriteLine("enter value: ");
                var val = decimal.Parse(Console.ReadLine());
                for (int i = 0; i < 30; i++)
                {
                    int i1 = i;
                    Task.Run(() => stockTicker.Notify(new StockTick()
                    {
                        Price = val, QuoteSymbol = symbol + i1
                    }));
                }
            }

            Console.WriteLine("Bye Bye");
        }
Пример #4
0
 private static void ManualSimulator(StockTicker stockTicker)
 {
     //////////////////////////////////////////////////////
     // A small program to let you enter the Ticks info. //
     // Symbol X will exit the program                   //
     //////////////////////////////////////////////////////
     while (true)
     {
         Console.Write("enter symbol (or x to exit): ");
         var symbol = Console.ReadLine();
         if (symbol.ToLower() == "x")
         {
             break;
         }
         Console.WriteLine("enter price: ");
         decimal price;
         if (decimal.TryParse(Console.ReadLine(), out price))
         {
             stockTicker.Notify(new StockTick()
             {
                 Price = price, QuoteSymbol = symbol
             });
         }
         else
         {
             Console.WriteLine("price should be decimal");
         }
     }
 }
Пример #5
0
 private static void ManualSimulator(StockTicker stockTicker)
 {
     //////////////////////////////////////////////////////
     // A small program to let you enter the Ticks info. //
     // Symbol X will exit the program                   //
     //////////////////////////////////////////////////////
     while (true)
     {
         Console.Write("enter symbol (or x to exit): ");
         var symbol = Console.ReadLine();
         if (symbol.ToLower() == "x")
         {
             break;
         }
         Console.WriteLine("enter price: ");
         decimal price;
         if (decimal.TryParse(Console.ReadLine(), out price))
         {
             stockTicker.Notify(new StockTick() { Price = price, QuoteSymbol = symbol });
         }
         else
         {
             Console.WriteLine("price should be decimal");
         }
     }
 }
Пример #6
0
        private static void Main(string[] args)
        {
            //
            // Uncomment the StockTicker version you wish to test
            //
            var stockTicker = new StockTicker();
            //var stockTicker = new RxStockMonitor(stockTicker);

            //
            // Uncomment to test the case of Concurrent Ticks
            //
            //TestConcurrentTicks(stockTicker);

            // A small program to let you enter the Ticks info.
            // Symbol X will exit the program
            while (true)
            {
                Console.Write("enter symbol: ");
                var symbol = Console.ReadLine();
                if (symbol.ToLower() == "x")
                {
                    break;
                }
                Console.WriteLine("enter value: ");
                var val = decimal.Parse(Console.ReadLine());
                for (int i = 0; i < 30; i++)
                {
                    int i1 = i;
                    Task.Run(() => stockTicker.Notify(new StockTick() { Price = val, QuoteSymbol = symbol + i1 }));
                }
            }

            Console.WriteLine("Bye Bye");
        }
Пример #7
0
 private void Emit()
 {
     Console.WriteLine("Emitting...");
     foreach (var stockTick in _ticks)
     {
         _ticker.Notify(stockTick);
     }
 }
Пример #8
0
 private static void TestConcurrentTicks(StockTicker stockTicker)
 {
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
     {
         Price = 100, QuoteSymbol = "MSFT"
     }));
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
     {
         Price = 150, QuoteSymbol = "INTC"
     }));
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
     {
         Price = 170, QuoteSymbol = "MSFT"
     }));
     ThreadPool.QueueUserWorkItem((_) => stockTicker.Notify(new StockTick()
     {
         Price = 195.5M, QuoteSymbol = "MSFT"
     }));
 }
Пример #9
0
        private static void Main(string[] args)
        {
            var stockTicker = new StockTicker();

            /////////////////////////////////////////////////////////////
            //                                                         //
            // 1. Uncomment the StockMonitor version you wish to test  //
            //                                                         //
            /////////////////////////////////////////////////////////////

            // Regular events StockMonitor
            var stockMonitor = new StockMonitor(stockTicker);

            // Rx StockMonitor
            //var stockMonitor = new RxStockMonitor(stockTicker);

            //////////////////////////////////////////////////////////////////
            //                                                              //
            // 2. (optional) Uncomment to test the case of Concurrent Ticks //
            //                                                              //
            //////////////////////////////////////////////////////////////////

            //TestConcurrentTicks(stockTicker);

            //////////////////////////////////////////////////////
            // A small program to let you enter the Ticks info. //
            // Symbol X will exit the program                   //
            //////////////////////////////////////////////////////
            while (true)
            {
                Console.Write("enter symbol (or x to exit): ");
                var symbol = Console.ReadLine();
                if (symbol.ToLower() == "x")
                {
                    break;
                }
                Console.WriteLine("enter price: ");
                decimal price;
                if (decimal.TryParse(Console.ReadLine(), out price))
                {
                    stockTicker.Notify(new StockTick() {Price = price, QuoteSymbol = symbol});
                }
                else
                {
                    Console.WriteLine("price should be decimal");
                }
            }

            GC.KeepAlive(stockMonitor);
            Console.WriteLine("Bye Bye");
        }
Пример #10
0
        private static void Main(string[] args)
        {
            //
            // Uncomment the StockTicker version you wish to test
            //
            var stockTicker = new StockTicker();

            //var stockTicker = new RxStockMonitor(stockTicker);

            //
            // Uncomment to test the case of Concurrent Ticks
            //
            //TestConcurrentTicks(stockTicker);

            // A small program to let you enter the Ticks info.
            // Symbol X will exit the program
            while (true)
            {
                Console.Write("enter symbol: ");
                var symbol = Console.ReadLine();
                if (symbol.ToLower() == "x")
                {
                    break;
                }
                Console.WriteLine("enter value: ");
                var val = decimal.Parse(Console.ReadLine());
                for (int i = 0; i < 30; i++)
                {
                    int i1 = i;
                    Task.Run(() => stockTicker.Notify(new StockTick()
                    {
                        Price = val, QuoteSymbol = symbol + i1
                    }));
                }
            }

            Console.WriteLine("Bye Bye");
        }