/// <summary> /// 更新单个选项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hlUpdate_Click(object sender, RoutedEventArgs e) { PollItemVM vm = this.PollItemInfoGrid.SelectedItem as PollItemVM; if (string.IsNullOrEmpty(vm.ItemName)) { CPApplication.Current.CurrentPage.Context.Window.Alert(ResNewsInfo.Information_PollItemNameIsNull, MessageType.Warning); } else { PollItem item = EntityConvertorExtensions.ConvertVM <PollItemVM, PollItem>(vm, (v, t) => { t.ItemName = new BizEntity.LanguageContent(ConstValue.BizLanguageCode, v.ItemName); }); //PollItemGroup item = vm.ConvertVM<PollItemVM, PollItemGroup>(); facade.UpdatePollItem(item, (obj, args) => { if (args.FaultsHandle()) { return; } CPApplication.Current.CurrentPage.Context.Window.Alert(ResNewsInfo.Information_OperateSuccessful, Newegg.Oversea.Silverlight.Controls.Components.MessageType.Information); PollItemInfoGrid.Bind(); }); } }
public IList <PollItem> GetPolls() { var returnValue = new List <PollItem>(); var pollItem = new PollItem { PollCount = 193, PollDescription = "Will Ben Affleck be a good Batman in the new Superman film?", PollImageAssett = Resource.Drawable.Ben_Affleck_Batman }; returnValue.Add(pollItem); pollItem = new PollItem { PollCount = 9, PollDescription = "Do popstars make good creative directors for technology companies?", PollImageAssett = Resource.Drawable.will_i_am_Intel }; returnValue.Add(pollItem); pollItem = new PollItem { PollCount = 27, PollDescription = "Should Microsoft produce a smartwatch to compete with the Apple Watch?", PollImageAssett = Resource.Drawable.Microsoft_Windows_Watch_concept }; returnValue.Add(pollItem); return(returnValue); }
public static void Main(string[] args) { using (var context = new Context(1)) { // Connect to task ventilator and weather server using (Socket receiver = context.Socket(SocketType.PULL), subscriber = context.Socket(SocketType.SUB)) { receiver.Connect("tcp://localhost:5557"); subscriber.Connect("tcp://localhost:5556"); subscriber.Subscribe("10001 ", Encoding.Unicode); var items = new PollItem[2]; items[0] = receiver.CreatePollItem(IOMultiPlex.POLLIN); items[0].PollInHandler += ReceiverPollInHandler; items[1] = subscriber.CreatePollItem(IOMultiPlex.POLLIN); items[1].PollInHandler += SubscriberPollInHandler; // Process messages from both sockets while (true) { context.Poll(items, -1); } } } }
/// <summary> /// Wait until message is ready to be received from the socket or until timeout is reached /// </summary> /// <param name="timeout"></param> /// <returns></returns> public bool Poll(TimeSpan timeout) { PollEvents events = GetPollEvents(); PollItem item = new PollItem(m_socketHandle, events); PollItem[] items = new PollItem[] { item }; ZMQ.Poll(items, (int)timeout.TotalMilliseconds); if (item.ResultEvent.HasFlag(PollEvents.PollError) && !IgnoreErrors) { Errors++; if (Errors > 1) { throw new ErrorPollingException("Error while polling", this); } } else { Errors = 0; } InvokeEvents(this, item.ResultEvent); return(items[0].ResultEvent != PollEvents.None); }
/// <summary> /// 编辑投票问题组选项 /// </summary> /// <param name="item"></param> public void UpdatePollItem(PollItem item) { DataCommand dc = DataCommandManager.GetDataCommand("Poll_UpdatePollItem"); dc.SetParameterValue <PollItem>(item); dc.ExecuteNonQuery(); }
private void RebuildPollset() { m_pollset = null; m_pollact = null; m_pollSize = m_sockets.Count + m_pollinSockets.Count; m_pollset = new PollItem[m_pollSize]; m_pollact = new NetMQSocket[m_sockets.Count]; uint itemNbr = 0; foreach (var socket in m_sockets) { m_pollset[itemNbr] = new PollItem(socket.SocketHandle, socket.GetPollEvents()); m_pollact[itemNbr] = socket; itemNbr++; } foreach (var socket in m_pollinSockets) { m_pollset[itemNbr] = new PollItem(socket.Key, PollEvents.PollError | PollEvents.PollIn); itemNbr++; } m_isDirty = false; }
protected void Page_Load(object sender, EventArgs e) { Poll1.ID = "Poll1"; Poll1.Title = "Favorite Programming Language"; Poll1.Question = "What is your favorite programming language?"; Poll1.AllowedVotesPerUser = 100; PollItem item1 = new PollItem(); item1.Text = "C#"; Poll1.Items.Add(item1); PollItem item2 = new PollItem(); item2.Text = "JavaScript"; Poll1.Items.Add(item2); PollItem item3 = new PollItem(); item3.Text = "Perl"; Poll1.Items.Add(item3); PollItem item4 = new PollItem(); item4.Text = "PHP"; Poll1.Items.Add(item4); PollItem item5 = new PollItem(); item5.Text = "Ruby"; Poll1.Items.Add(item5); PollItem item6 = new PollItem(); item6.Text = "VB"; Poll1.Items.Add(item6); phPoll1.Controls.Add(Poll1); }
public void ShouldAllowInfinitePolling() { Ctx contextNew = ZMQ.CtxNew(); SocketBase receiver = ZMQ.Socket(contextNew, ZmqSocketType.Dealer); ZMQ.Bind(receiver, "inproc://test"); Task.Factory.StartNew(() => { Thread.Sleep(500); SocketBase sender = ZMQ.Socket(contextNew, ZmqSocketType.Dealer); ZMQ.Connect(sender, "inproc://test"); ZMQ.Send(sender, "ping", SendReceiveOptions.None); ZMQ.Close(sender); }); var pollItems = new PollItem[] { new PollItem(receiver, PollEvents.PollIn) }; Assert.DoesNotThrow(() => ZMQ.Poll(pollItems, -1)); var msg = ZMQ.Recv(receiver, SendReceiveOptions.DontWait); var actual = Encoding.ASCII.GetString(msg.Data, 0, msg.Size); Assert.AreEqual("ping", actual); ZMQ.Close(receiver); ZMQ.Term(contextNew); }
/// <summary> /// Creates the poll. /// </summary> /// <returns></returns> private PollItem CreatePoll() { TemplateItem pollTemplate = PollConstants.DatabaseContext.Templates[PollConstants.PollTemplateID]; string pollName = GetItemName(PollingName.Value.Trim()).Trim(); Item item; if (ParentItem.TemplateID == PollConstants.PollTemplateID) { item = ParentItem.Parent.Add(pollName, pollTemplate); Assert.IsNotNull(item, "Can't create poll item"); var archivedPoll = new PollItem(ParentItem); archivedPoll.ArchiveTo(item); } else { item = ParentItem.Add(pollName, pollTemplate); } PollItem pollItem = new PollItem(item); if (pollName != PollingName.Value.Trim()) { pollItem.DisplayName = HttpContext.Current.Server.HtmlEncode(PollingName.Value.Trim()); } pollItem.Intro = string.Format("<h1>{0}</h1>", PollingName.Value.Trim()); CreateOptions(pollItem); return(pollItem); }
public static void Main(string[] args) { using (var context = new Context(1)) { using (Socket receiver = context.Socket(SocketType.PULL), sender = context.Socket(SocketType.PUSH), controller = context.Socket(SocketType.SUB)) { receiver.Connect("tcp://localhost:5557"); sender.Connect("tcp://localhost:5558"); controller.Connect("tcp://localhost:5559"); controller.Subscribe(string.Empty, Encoding.Unicode); bool run = true; var items = new PollItem[2]; items[0] = receiver.CreatePollItem(IOMultiPlex.POLLIN); items[0].PollInHandler += (socket, revents) => ReceiverPollInHandler(socket, sender); items[1] = controller.CreatePollItem(IOMultiPlex.POLLIN); items[1].PollInHandler += delegate { run = false; }; // Process tasks as long as the controller does not signal the end. while (run) { context.Poll(items); } } } }
/// <summary> /// 保存投票选项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, RoutedEventArgs e) { //if (!ValidationManager.Validate(this.PollItemInfo)) if (string.IsNullOrEmpty(model.ItemName.Trim())) { CPApplication.Current.CurrentPage.Context.Window.Alert(ResNewsInfo.Information_PollItemNameIsNull, MessageType.Warning); } else { PollItem item = EntityConvertorExtensions.ConvertVM <PollItemVM, PollItem>(model, (v, t) => { t.ItemName = new BizEntity.LanguageContent(ConstValue.BizLanguageCode, v.ItemName); }); item.PollCount = 0; item.PollItemGroupSysNo = SysNo; facade.CreatePollItem(item, (obj, args) => { if (args.FaultsHandle()) { return; } CPApplication.Current.CurrentPage.Context.Window.Alert(ResNewsInfo.Information_CreateSuccessful, Newegg.Oversea.Silverlight.Controls.Components.MessageType.Information); PollItemInfoGrid.Bind(); }); } }
public IActionResult Create(PollCreateDto model, IFormFile file) { var poll = new Poll(); _mapper.Map(model.Poll, poll); poll.Created = DateTime.Now; var pollitem = new PollItem(); _mapper.Map(model.Item, pollitem); poll.PollItems.Add(pollitem); var pollImage = new Image(); if (file != null) { pollImage.FileName = Path.GetFileName(file.FileName); pollImage.Content = ImageHelper.ReadImage(file.OpenReadStream()); pollitem.Images.Add(pollImage); } _context.Add(poll); _context.Add(pollitem); if (pollImage.Content != null) { pollitem.Images.Add(pollImage); _context.Add(pollImage); } _context.SaveChanges(); return(RedirectToAction("Index")); }
public static void RunDBHandler(IDatabaseHandler _dbHandler) { dbHandler = _dbHandler; //if the DB handler is ever moved outside of this process, it should be responsible for bind // rather than this connect QueueDBHandlerComm = DBHandlerContext.Socket(SocketType.REP); QueueDBHandlerComm.Connect("inproc://dbhandler"); PollItem[] ControlPoller = new PollItem[1]; ControlPoller[0] = QueueDBHandlerComm.CreatePollItem(IOMultiPlex.POLLIN); ControlPoller[0].PollInHandler += new PollHandler(ValkQueueDBHandler_PollInHandler); Stopwatch Watch = new Stopwatch(); TotalWatch.Start(); Watch.Start(); while (!Exit) { //reasonable to block for a second DBHandlerContext.Poll(ControlPoller, 1000); //get 5 seconds worth of DB entries if (StepsToUpdate.Count > 0 && (Watch.Elapsed.Seconds >= 5 || StepsToUpdate.Count > 1000)) { TotalSteps += StepsToUpdate.Count(); Console.WriteLine(StepsToUpdate.Count.ToString() + "," + Watch.Elapsed.TotalSeconds + "," + TotalSteps + "," + TotalWatch.Elapsed.TotalSeconds); DoUpdates(); Watch.Stop(); Watch.Reset(); Watch.Start(); } } }
/// <summary> /// 检查是否可以创建该投票子项 /// </summary> /// <param name="item"></param> /// <returns></returns> public bool CheckCreatePollItem(PollItem item) { DataCommand dc = DataCommandManager.GetDataCommand("Poll_CheckCreatePollItem"); dc.SetParameterValue <PollItem>(item); return(dc.ExecuteScalar() != null); }
public override CommandState QueryState(CommandContext context) { if (context.Items.Length != 1) { return(CommandState.Disabled); } Item poll = context.Items[0]; if (!poll.Access.CanWrite()) { return(CommandState.Disabled); } PollItem pollItem = new PollItem(context.Items[0]); if (pollItem.IsClosed) { return(CommandState.Disabled); } if (pollItem.IsArchived) { return(CommandState.Disabled); } return(CommandState.Enabled); }
static void Main(string[] args) { sensor = KinectSensor.KinectSensors[0]; if (sensor.Status == KinectStatus.Connected) { Console.WriteLine("Connected..."); sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); sensor.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady); sensor.SkeletonStream.Enable(); sensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady); sensor.DepthStream.Enable(); sensor.DepthFrameReady += new EventHandler <DepthImageFrameReadyEventArgs>(sensor_DepthFrameReady); context = new Context(1); socket = context.Socket(SocketType.PUB); socket.Bind("tcp://*:20001"); depthSocket = context.Socket(SocketType.PUB); depthSocket.Bind("tcp://*:20002"); imgSocket = context.Socket(SocketType.PUB); imgSocket.Bind("tcp://*:20003"); elevationSocket = context.Socket(SocketType.REP); elevationSocket.Bind("tcp://*:20004"); var items = new PollItem[1]; items[0] = elevationSocket.CreatePollItem(IOMultiPlex.POLLIN); items[0].PollInHandler += new PollHandler(Program_PollInHandler); sensor.Start(); bool interrupted = false; Console.CancelKeyPress += delegate { interrupted = true; }; while (!interrupted) { context.Poll(items, -1); } } }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,CreatedBy,Description,TotalVoteCount,disabled")] PollItem pollItem) { if (id != pollItem.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pollItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PollItemExists(pollItem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(pollItem)); }
public PollDetailsViewModel(PollItem poll) { Poll = poll; Title = poll.Proposition; PollChoices = new ObservableCollection <PollChoice>(); LoadCommand = new Command(async() => await ExecuteLoadChoicesCommand()); VoteCommand = new Command <int>(async s => await ExecuteVote(s)); pollDetailsService = new PollDetailsService(poll); }
/// <summary> /// 编辑投票问题组选项 /// </summary> /// <param name="item"></param> public virtual void UpdatePollItem(PollItem item) { if (pollItemDA.CheckCreatePollItem(item)) { throw new BizException(ResouceManager.GetMessageString("MKT.News", "Advertiser_PollItemNameISTheSame")); } else { pollItemDA.UpdatePollItem(item); } }
public PollDetailsViewModel(String uuid) { Console.WriteLine("New PollDetailsView from uuid " + uuid); Title = "Chargement..."; Poll = new PollItem(); Poll.Uuid = new Guid(uuid); PollChoices = new ObservableCollection <PollChoice>(); LoadCommand = new Command(async() => await ExecuteLoadCommand()); VoteCommand = new Command <int>(async s => await ExecuteVote(s)); pollDetailsService = new PollDetailsService(Poll.Uuid); }
public static MvcHtmlString ProgressBar(this HtmlHelper helper, PollItem item, int count) { float percent = 0; float total = item.Option1Count + item.Option2Count + item.Option3Count + item.Option4Count + item.Option5Count + item.Option6Count; if (count != 0) { percent = (float)count / total * 100; } return(MvcHtmlString.Create(string.Format("<div class='progress-bar'><span>{0:0}%</span><div style='width: {0:0}%'></div></div>", percent))); }
public async Task <IActionResult> Create([Bind("Id,CreatedBy,Description,TotalVoteCount,disabled")] PollItem pollItem) { if (ModelState.IsValid) { pollItem.Id = Guid.NewGuid(); _context.Add(pollItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(pollItem)); }
private PollItem GetCurrentPoll() { try { PollItem poll = new PollItem(PollConstants.DatabaseContext.GetItem(PathToPoll)); return(poll); } catch (ArgumentNullException e) { throw new MissedItemException(String.Format("Invalid {0} parameter", PollConstants.PollPathParameter), e); } }
public void Broker() { // Initialize poll set PollItem[] pollItems = new PollItem[2]; pollItems[0] = frontend.CreatePollItem(IOMultiPlex.POLLIN); pollItems[0].PollInHandler += new PollHandler(FrontendPollInHandler); pollItems[1] = backend.CreatePollItem(IOMultiPlex.POLLIN); pollItems[1].PollInHandler += new PollHandler(BackendPollInHandler); // Switch messages between sockets while (true) { context.Poll(pollItems, -1); } }
public async Task <PollItem> GetPoll() { string rawPoll = await App.ApiService.ApiRequest("https://citizen.navispeed.eu/api/poll/poll/" + poll.Uuid, HttpMethod.Get); Console.WriteLine(rawPoll); if (String.IsNullOrEmpty(rawPoll)) { return(null); } poll = JsonConvert.DeserializeObject <PollItem>(rawPoll); Console.WriteLine("Le poll c'est " + poll.Proposition); return(poll); }
public static void ProcessingLoop() { if (!SlipstreamEnvironment.Initialized) { throw new InvalidOperationException( "Unable to start PRC-Handler thread, please initialize the environment first."); } var broadcastUrl = SlipstreamEnvironment.Settings.BroadcastUrl; var rpcHandlerUrl = SlipstreamEnvironment.Settings.RpcHandlerUrl; var id = Guid.NewGuid(); LoggerProvider.EnvironmentLogger.Debug( () => string.Format("Starting RpcHandler thread[{0}] URL=[{1}] ...", id, rpcHandlerUrl)); using (var broadcastSocket = new ZMQ.Socket(ZMQ.SocketType.SUB)) using (var receiver = new ZMQ.Socket(ZMQ.SocketType.REP)) { broadcastSocket.Connect(broadcastUrl); broadcastSocket.Subscribe("STOP-RPC", Encoding.UTF8); LoggerProvider.EnvironmentLogger.Debug( () => string.Format("RpcHandler thread[{0}] is connected to the Commander URL[{1}]", id, broadcastUrl)); receiver.Connect(rpcHandlerUrl); var items = new PollItem[2]; items[0] = broadcastSocket.CreatePollItem(IOMultiPlex.POLLIN); items[0].PollInHandler += new PollHandler(BusControllerPollInHandler); items[1] = receiver.CreatePollItem(IOMultiPlex.POLLIN); items[1].PollInHandler += new PollHandler(ReceiverPollInHandler); lock (s_lockObj) { s_running = true; } // Process messages from both sockets while (s_running) { Context.Poller(items, -1); } LoggerProvider.EnvironmentLogger.Debug( () => string.Format("The RpcHandler thread[{0}] is stopped", id)); } }
public void RunPipeline(Sockets.PairSocket shim) { m_pipe = shim; shim.SignalOK(); while (!m_terminated) { PollItem[] pollItems = new PollItem[] { new PollItem(m_pipe.SocketHandle, PollEvents.PollIn), new PollItem(m_udpSocket, PollEvents.PollIn), }; long timeout = -1; if (m_transmit != null) { timeout = m_pingAt - Clock.NowMs(); if (timeout < 0) { timeout = 0; } } ZMQ.Poll(pollItems, m_udpSocket != null ? 2 : 1, (int)timeout); if (pollItems[0].ResultEvent.HasFlag(PollEvents.PollIn)) { HandlePipe(); } if (pollItems[1].ResultEvent.HasFlag(PollEvents.PollIn)) { HandleUdp(); } if (m_transmit != null && Clock.NowMs() > m_pingAt) { SendUdpFrame(m_transmit); m_pingAt = Clock.NowMs() + m_interval; } } m_udpSocket.Dispose(); }
public static void RunQueue(IDatabaseHandler dbHandler) { if (QueueContext == null) { throw new System.Exception("PollContext not set"); } QueueComm = QueueContext.Socket(SocketType.REP); //Bind the comm to an inprocess channel and a TCP channel QueueComm.Bind("tcp://*:5000"); QueueComm.Bind("inproc://queueself"); QueueControllerIntraComm = QueueContext.Socket(SocketType.REP); QueueControllerIntraComm.Connect("inproc://queuecontrol"); //if the DB handler is ever moved outside of this process, it should be responsible for bind // rather than this class QueueDBHandlerComm = QueueContext.Socket(SocketType.REQ); QueueDBHandlerComm.Bind("inproc://dbhandler"); PollItem[] ControlPoller = new PollItem[1]; ControlPoller[0] = QueueControllerIntraComm.CreatePollItem(IOMultiPlex.POLLIN); ControlPoller[0].PollInHandler += new PollHandler(ValkQueueWFStepsCTRL_PollInHandler); PollItem[] QueuePoller = new PollItem[1]; QueuePoller[0] = QueueComm.CreatePollItem(IOMultiPlex.POLLIN); QueuePoller[0].PollInHandler += new PollHandler(ValkQueueWFSteps_PollInHandler); //setup DB handler ValkQueueDBHandler.DBHandlerContext = QueueContext; DBHandler = new Thread(() => ValkQueueDBHandler.RunDBHandler(dbHandler)); DBHandler.Start(); //main loop while (!Exit) { //we may want a way to shut this down... QueueContext.Poll(ControlPoller, 1); if (!Stop) { //block for a little while... QueueContext.Poll(QueuePoller, 1000); } } }
/// <summary> /// 处理服务器套接字 /// </summary> /// <param name="item">待处理的PollItem</param> private void HandleServerSocket(PollItem item) { //如果出错或者挂起,则关闭连接 if ((item.Mode & (PollMode.PollError | PollMode.PollHangUp)) != 0) { poll.Unregister(server); server.Close(); } //否则建立一个新的socket,然后让侦听中的插口去accept它,以后数据的读写应该在新的socket中进行。 else { Socket newSocket = server.Accept(); newSocket.Blocking = false; SingleSocket newSingleSocket = new SingleSocket(this, newSocket, handler); singleSocketDictionary[newSocket.Handle] = newSingleSocket; poll.Register(newSocket, PollMode.PollIn); handler.MakeExternalConnection(newSingleSocket); } }
protected void Page_Load(object sender, EventArgs e) { Poll1.ID = "Poll1"; Poll1.VotingMode = PollVotingMode.SingleAnswer; Poll1.MinAnswers = 1; Poll1.Title = "Favorite Programming Language"; Poll1.Question = "What is your favorite programming language?"; Poll1.AllowedVotesPerUser = 100; PollItem item1 = new PollItem(); item1.Text = "C#"; Poll1.Items.Add(item1); PollItem item2 = new PollItem(); item2.Text = "JavaScript"; Poll1.Items.Add(item2); PollItem item3 = new PollItem(); item3.Text = "Perl"; Poll1.Items.Add(item3); PollItem item4 = new PollItem(); item4.Text = "PHP"; Poll1.Items.Add(item4); PollItem item5 = new PollItem(); item5.Text = "Ruby"; Poll1.Items.Add(item5); PollItem item6 = new PollItem(); item6.Text = "VB"; Poll1.Items.Add(item6); phPoll1.Controls.Add(Poll1); }
public static NetMQMessage ReceiveMessage(this NetMQSocket socket, TimeSpan timeout) { var item = new PollItem(socket.SocketHandle, PollEvents.PollIn); var items = new[] { item }; ZMQ.Poll(items, (int)timeout.TotalMilliseconds); if (item.ResultEvent.HasFlag(PollEvents.PollError) && !socket.IgnoreErrors) { throw new ErrorPollingException("Error while polling", socket); } if (!item.ResultEvent.HasFlag(PollEvents.PollIn)) { return(null); } var msg = socket.ReceiveMessage(); return(msg); }
public int Poll(PollItem[] pollItems, int timeoutMilliseconds) { return LibZmq.zmq_poll(pollItems, pollItems.Length, timeoutMilliseconds * LibZmq.PollTimeoutRatio); }
public PollManager() { SilentTimers = new List<SilentTimer>(); PollQueue = new Queue<PollItem>(); ResumePollEvent = new ManualResetEvent(false); PollThread = new Thread(delegate() { try { while (PollThread.IsAlive) { if (PollQueue.Count == 0 || SilentTimers.Count > 0) { if (lastBusyState == true && PollManagerChangeStateEvent != null) { PollManagerChangeStateEvent(false); } lastBusyState = false; ResumePollEvent.Reset(); ResumePollEvent.WaitOne(); } else { if (lastBusyState == false && PollManagerChangeStateEvent != null) { PollManagerChangeStateEvent(true); } lastBusyState = true; CurrentPollItem = PollQueue.Dequeue(); if (CurrentPollItem != null) { DonePollEvent = new ManualResetEvent(false); DonePollTimer = new System.Timers.Timer(90000); DonePollTimer.Elapsed += delegate(object s, ElapsedEventArgs ev) { DonePollTimer.Stop(); DonePollEvent.Set(); CurrentPollItem.Terminate(); }; DonePollTimer.Start(); CurrentPollItem.Action(delegate() { if (DonePollTimer != null) { DonePollTimer.Stop(); } if (DonePollEvent != null) { DonePollEvent.Set(); } }); DonePollEvent.WaitOne(); if (PollThread.ThreadState != ThreadState.AbortRequested && PollThread.ThreadState != ThreadState.Aborted && PollManagerUpdateUnitStateEvent != null) { PollManagerUpdateUnitStateEvent(CurrentPollItem.Unit); } } } } } catch (ThreadAbortException e) { } }); }
protected string GetVoteImageWidthPercent(PollItem pollItem, int voteTotalCount, int widthPercent) { voteTotalCount = voteTotalCount == 0 ? 1 : voteTotalCount; return (((float)pollItem.PollItemCount / (float)voteTotalCount) * widthPercent).ToString(); }