Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class MainForm : Form
- {
- public void videoImage(Image image)
- {
- this.VideoViewer.Image = image;
- if (this.InvokeRequired)
- {
- this.Invoke(new MethodInvoker(delegate { videoImage(image); }));
- }
- }
- public void mapImage(Image image)
- {
- this.VideoViewer.Image = image;
- if (this.InvokeRequired)
- {
- this.Invoke(new MethodInvoker(delegate { mapImage(image); }));
- }
- }
- }
- public delegate void videoImageReady(System.Drawing.Image image);
- public event videoImageReady videoImage;
- public delegate void mapImageReady(System.Drawing.Image image);
- public event mapImageReady mapImage;
- // this is called from any thread
- public void videoImage(Image image)
- {
- // are we called from the UI thread?
- if (this.InvokeRequired)
- {
- // no, so call this method again but this
- // time use the UI thread!
- // the heavy-lifting for switching to the ui-thread
- // is done for you
- this.Invoke(new MethodInvoker(delegate { videoImage(image); }));
- }
- // we are now for sure on the UI thread
- // so update the image
- this.VideoViewer.Image = image;
- }
- if (this.InvokeRequired)
- {
- this.Invoke(new MethodInvoker(delegate { videoImage(image); }));
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement