0

If I create two different threads for each plot so is it possible to combine both the plots and display in a one picture box?

I have tried it using single thread but I couldn't get the desired result. here is the code which I have tried:

The output of the code is shown in the following link. Code Output (Click here)

I need a suggestion what should I do in this case and where I am mistaken? please help!!

SN25
  • 69
  • 1
  • 12
  • 2
    Possible maybe. But a very bad idea. Why do you think you need this? – H H Sep 20 '17 at 06:47
  • 1
    Yes, but be careful about cross-thread ownership of GDI objects, and ensure that you swap or splot the PicturBox's offscreen buffer only in the UI thread. But can you provide some expositionary backstory? Why do you have multithreaded picture-box plotting? Why won't single-thread do? If you're after high-performance then use Direct2D or OpenGL instead of the now deprecated (and poorly-performing) GDI. – Dai Sep 20 '17 at 06:47
  • @HenkHolterman If you refer to my previous posts you will get the idea of it Why I am thinking like that because I am a beginner to C# programming related to graphics. and I have to plot two graphics using same data but in different manner. – SN25 Sep 20 '17 at 07:01
  • 1
    We should not have to go fishing into your other questions. If you want an answer, it is worth providing the information here. – Gusdor Sep 20 '17 at 07:13
  • @Dai I used single thread but I couldn't refresh the picture box, I need to refresh the picture box to redraw each graphic – SN25 Sep 20 '17 at 07:25
  • 1
    The GUI (GDI) is single threaded an not thread-safe. Using other threads will only add to your problems. – H H Sep 20 '17 at 07:33
  • 1
    This is an [XY question](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Think about what you really need and write a [mcve] for it – H H Sep 20 '17 at 07:34
  • Hi Gudsor and HenkHolterman, ok sure Let me edit my question here – SN25 Sep 20 '17 at 07:34
  • The way to go is to give up on the wrong idea and go back to the original question. The comments there lead the way.. (not the answer, though!) – TaW Sep 20 '17 at 07:41
  • I have edited my question please have a look... – SN25 Sep 20 '17 at 07:42
  • When you run this in Debug mode it should throw an exception. Unless you have messed with CheckForIllegalCrossThreadCalls , which you shouldn't do. – H H Sep 20 '17 at 08:01
  • but it doesn't show any error or exception – SN25 Sep 20 '17 at 08:04

0 Answers0