Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. public partial class MainForm : Form
  2. {
  3.  
  4. public void videoImage(Image image)
  5. {
  6. this.VideoViewer.Image = image;
  7. if (this.InvokeRequired)
  8. {
  9. this.Invoke(new MethodInvoker(delegate { videoImage(image); }));
  10. }
  11. }
  12.  
  13. public void mapImage(Image image)
  14. {
  15. this.VideoViewer.Image = image;
  16. if (this.InvokeRequired)
  17. {
  18. this.Invoke(new MethodInvoker(delegate { mapImage(image); }));
  19. }
  20. }
  21.  
  22. }
  23.  
  24. public delegate void videoImageReady(System.Drawing.Image image);
  25. public event videoImageReady videoImage;
  26.  
  27. public delegate void mapImageReady(System.Drawing.Image image);
  28. public event mapImageReady mapImage;
  29.  
  30. // this is called from any thread
  31. public void videoImage(Image image)
  32. {
  33. // are we called from the UI thread?
  34. if (this.InvokeRequired)
  35. {
  36. // no, so call this method again but this
  37. // time use the UI thread!
  38. // the heavy-lifting for switching to the ui-thread
  39. // is done for you
  40. this.Invoke(new MethodInvoker(delegate { videoImage(image); }));
  41. }
  42. // we are now for sure on the UI thread
  43. // so update the image
  44. this.VideoViewer.Image = image;
  45. }
  46.  
  47. if (this.InvokeRequired)
  48. {
  49. this.Invoke(new MethodInvoker(delegate { videoImage(image); }));
  50. return;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement