private async void GetMetric_Click(object sender, RoutedEventArgs e) { PlcClient c = this.FirstPlcClient; if (c == null) { this.LogMessage("目前没有 PLC 连接。"); return; } this.LogMessage("Sending GetMetricRequest"); this.SendingDocument.Blocks.Clear(); this.ReceivingDocument.Blocks.Clear(); try { Metric response = await c.GetMetricAsync( new GetMetricRequest(), deadline : DateTime.Now.AddSeconds(30)) .ConfigureAwait(true); this.LogMessage("Received GetMetricResponse " + response.ToString()); } catch (RpcException ex) { this.LogMessage("Failed to receive GetMetricResponse " + ex.ToString()); } }