private static void ProduceDataChanges(object state) { var server = (OpcServer)state; while (!producerControl.IsCancellationRequested) { lock (state) { unchecked { foreach (var node in dataNodes) { node.Value++; } } timestampNode.Value = DateTime.UtcNow; dataNode.ApplyChanges(server.SystemContext, recursive: true); } Console.WriteLine("{0} BULK: New Data available - pausing for {1} ms.", DateTime.Now, Interval); // Wait for "Stop" or perform next bulk changes after interval elapsed if (producerControl.Token.WaitHandle.WaitOne(Interval)) { break; } } }
private static void ProduceDataChanges(object state) { var server = (OpcServer)state; while (!producerControl.IsCancellationRequested) { lock (state) { dataAvailableNode.Value = false; dataAvailableNode.ApplyChanges(server.SystemContext); unchecked { foreach (var node in dataNodes) { node.Value++; } } dataProcessedNode.Value = false; dataAvailableNode.Value = true; timestampNode.Value = DateTime.UtcNow; dataNode.ApplyChanges(server.SystemContext, recursive: true); } try { do { Console.WriteLine("{0} HANDSHAKE: New Data available - awaiting data being processed.", DateTime.Now); } while (!dataProcessed.Wait(Interval, producerControl.Token)); Console.WriteLine("{0} HANDSHAKE: Completed - processing for {1} ms.", DateTime.Now, Interval); // Wait for "Stop" or perform next handshake changes after interval elapsed if (producerControl.Token.WaitHandle.WaitOne(Interval)) { break; } } catch (OperationCanceledException) { break; } } }