コード例 #1
0
        private async Task WatchForNewData(BatchBlock <KernelWindow> bb)
        {
            do
            {
                var data = await bb.ReceiveAsync();

                Dispatcher.Invoke(() =>
                {
                    DataList.AddRange(data);
                    OutputList.Items.Refresh();
                    OutputList.ScrollIntoView(data.Last());
                });

                await Task.Delay(50);
            } while (true);
        }
コード例 #2
0
        private void AddOutput(string output)
        {
            // Prefix DT
            output = DateTime.Now.ToString("HH:mm:ss") + " " + output;

            // Debug it
            Debug.WriteLine(output);

            // Add to the list
            OutputList.Items.Add(output);

            // If there is no selection or the current selection is the last entry, auto scroll
            if ((OutputList.SelectedItem == null) || ((string)OutputList.SelectedItem == lastOutput))
            {
                // Select the new output
                OutputList.SelectedItem = output;

                // Auto scroll
                OutputList.ScrollIntoView(output, ScrollIntoViewAlignment.Leading);
            }

            // Update last output
            lastOutput = output;
        }