M
M
mihzas2015-09-13 23:20:50
C++ / C#
mihzas, 2015-09-13 23:20:50

How to organize inter-thread communication in winforms?

There are two threads, one of them inverts the image, the other should display the process of inverting itself using a progress bar. The question is how to transfer information from the stream that inverts the picture to the stream that displays the process.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2015-09-14
@mihzas

The hard way: take a ConcurrentQueue , write a small message class, pass progress messages from a worker thread to a GUI thread (in a GUI thread, you check the message queue on a timer).
Another option, simpler, is to wrap the workflow in a converter class, make this class have a ProgressChanged event, pull the event using Invoke.
In general, there is a BackgroundWorker for this purpose - this is the easiest option, just right for you.
PS do not forget to use LockBits, otherwise it will work slowly.

D
dordzhiev, 2015-09-14
@dordzhiev

IProgress, BackgroundWorker

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question