Over a million developers have joined DZone.

Safe Update Of Windows Control From Other Threads

DZone's Guide to

Safe Update Of Windows Control From Other Threads

Free Resource

        delegate void UpdateReportCallback(string text);
        private void UpdateReport(string message)
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.textBoxReport.InvokeRequired)
                UpdateReportCallback d = new UpdateReportCallback(UpdateReport);
                this.Invoke(d, new object[] { message });
                textBoxReport.Text = message + System.Environment.NewLine + textBoxReport.Text;

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}