private static Results MatchMultiProcessor(string userAgent, SegmentHandler handler) { // Provide an object to signal when the request has completed. AutoResetEvent waiter = new AutoResetEvent(false); // Create the request. Request request = new Request(userAgent, handler, waiter); if (request.Count > 0) { // For each thread add this to the queue. for (int i = 0; i < Environment.ProcessorCount; i++) { ThreadPool.QueueUserWorkItem(ServiceRequest, request); } // Wait until a signal is received. Keeping coming back to // this thread so that a request to close the request // can be processed. while (waiter.WaitOne(1, false) == false) { // Do nothing } ; } // Return the results. return(request.Results); }
private static Results MatchSingleProcessor(string userAgent, SegmentHandler handler) { // Create a segment matcher request. Request request = new Request(userAgent, handler); // Process the request. ServiceRequest(request); // Return the results. return(request.Results); }
MyForm() { Text = "NetDraw"; try { RemotingConfiguration.Configure("NetDraw.exe.config"); VirtualPaper = new Paper(); VirtualPaper.NewSegment += (SH = new SegmentHandler(OnNewSegment)); VirtualPaper.LastSegment += (EH = new EndHandler(OnLastSegment)); VirtualPaper.ClearAll += (CH = new ClearHandler(OnClear)); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } strokes = VirtualPaper.GetStrokes(); }
internal static Results Match(string userAgent, SegmentHandler handler) { if (handler.UserAgents.Count > 0) { if (Environment.ProcessorCount > 1 && Detection.Constants.ForceSingleProcessor == false) { return(MatchMultiProcessor(userAgent, handler)); } else { return(MatchSingleProcessor(userAgent, handler)); } } return(null); }
internal Request(string userAgent, SegmentHandler handler, AutoResetEvent completeEvent) : base(userAgent, handler, completeEvent) { _target = Handler.CreateSegments(userAgent); _results = new Results(); }
internal Request(string userAgent, SegmentHandler handler) : base(userAgent, handler) { _target = Handler.CreateSegments(userAgent); _results = new Results(); }