Beispiel #1
0
 internal static void ProcessInvoice(BranchInvoiceData invoiceData)
 {
     // Apply VBLock to queue requests from the same branches
     using (var lockObj = new VBDisposableLock(invoiceData.BranchId))
     {
         InvoiceConsumer.Consume(invoiceData);
     }
 }
Beispiel #2
0
        internal void StartSendingdData()
        {
            isTaskLoopEnabled = true;

            for (int i = 0; i < cashDeskTasks.Length; i++)
            {
                cashDeskTasks[i] = Task.Run(() =>
                {
                    Random r = new Random();
                    while (isTaskLoopEnabled)
                    {
                        BranchInvoiceData newInvoice = new BranchInvoiceData(BranchId, string.Concat(BranchId, " invoice at ", DateTime.UtcNow));
                        Console.WriteLine(string.Concat("Invoice: ", newInvoice.Data, " is created and going to be processed..."));
                        InvoiceProcessingService.ProcessInvoice(newInvoice);
                        Thread.Sleep(r.Next(2500) + 2500);
                    }
                });
            }
        }
Beispiel #3
0
 internal static void Consume(BranchInvoiceData invoice)
 {
     // Do some processing stuff...
     Console.WriteLine(string.Concat("Invoice: ", invoice.Data, " is processed."));
     Thread.Sleep(2000);
 }