Ejemplo n.º 1
0
        void CWThread_TickAsyncPD()
        {
            bool DisplayFlag = true;

            while (true)
            {
                int length = MemoryManager.EndOfDownloadCount;//MemoryManager.TradeMemoryConDict.Count;

                if (length == initialStartPointCWAsync && DisplayFlag)
                {
                    DisplayFlag = false;
                    NetPositionMemory.UpdateClientNetPosition("", MemoryManager.NetPositionCWDemoDict.ToList());
                    //TODO call CWSW for pd
                    NetPositionMemory.UpdateCWSWDNetPosition("", MemoryManager.NetPositionCWDemoDict.ToList());
                    ProcessClientWiseTradeAsyncOnline();
                    thCWPersonalDownload.Abort();
                }

                if (MemoryManager.TradeMemoryConDict.Count > 0 && length > initialStartPointCWAsync)
                {
                    ParallelOptions oParallelOptions = new ParallelOptions();
                    oParallelOptions.MaxDegreeOfParallelism = 1;

                    Parallel.For(initialStartPointCWAsync, length, oParallelOptions, (index) =>
                    {
                        lock (newCWobjectAsync)
                        {
                            if (MemoryManager.TradeMemoryConDict.ContainsKey(index))
                            {
                                CommonFrontEnd.Processor.UMSProcessor.ProcessNetPositionCWDemo(MemoryManager.TradeMemoryConDict[index]);
                            }
                        }
                    });

                    initialStartPointCWAsync = length;
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
Ejemplo n.º 2
0
        void CWThread_TickAsyncOnline()
        {
            while (true)
            {
                int length = MemoryManager.TradeMemoryConDict.Count;

                //initialStartPointCWAsync = MemoryManager.EndOfDownloadCount;
                if (MemoryManager.TradeMemoryConDict.Count > 0 && length > initialStartPointCWAsync)
                {
                    ParallelOptions oParallelOptions = new ParallelOptions();
                    oParallelOptions.MaxDegreeOfParallelism = 1;

                    Parallel.For(initialStartPointCWAsync, length, oParallelOptions, (index) =>
                    {
                        lock (newCWobjectAsync)
                        {
                            if (MemoryManager.TradeMemoryConDict.ContainsKey(index))
                            {
                                CommonFrontEnd.Processor.UMSProcessor.ProcessNetPositionCWDemo(MemoryManager.TradeMemoryConDict[index]);
                                if (UtilityLoginDetails.GETInstance.Role.ToLower() == "trader")
                                {
                                    NetPositionMemory.UpdateClientNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).Client.Trim(), MemoryManager.NetPositionCWDemoDict.Where(x => ((CommonFrontEnd.Model.Trade.NetPosition)x.Value).ClientId == ((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).Client.Trim()).ToList());
                                    NetPositionMemory.UpdateCWSWDNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).Client.Trim(), MemoryManager.NetPositionCWDemoDict.ToList());
                                }
                                else if (UtilityLoginDetails.GETInstance.Role.ToLower() == "admin")
                                {
                                    NetPositionMemory.UpdateClientNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).TraderId.ToString(), MemoryManager.NetPositionCWDemoDict.Where(x => ((CommonFrontEnd.Model.Trade.NetPosition)x.Value).TraderId == ((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).TraderId.ToString()).ToList());
                                    NetPositionMemory.UpdateCWSWDNetPosition(((CommonFrontEnd.Model.Trade.TradeUMS)MemoryManager.TradeMemoryConDict[index]).TraderId.ToString(), MemoryManager.NetPositionCWDemoDict.ToList());
                                }
                            }
                        }
                    });

                    initialStartPointCWAsync = length;
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }