0

I don't know if I need to give more information but I have been browsing through my code and I couldn't find anything else that causes this problem.

I have a WriteableBitmap somewhere inside my code that I only declare via WriteableBitmap wb;

Now giving only that information, when I now close the main window, the debugging process in VS 2013 stops and everything seems to be fine. However, when I initialize wb as in

wb = new WriteableBitmap(dimx, dimy, 96, 96, PixelFormats.Indexed8, paletteGray);

not running any other line of code afterwards and then close the window, VS doesn't seem to stop debugging, meaning I have to click on the "stop" button to stop everything running, which also takes a long time (up to 15 seconds) after I initialize wb.

Is there maybe anything I am missing about WriteableBitmap here?

philkark
  • 2,417
  • 7
  • 38
  • 59
  • 1
    I'd say no, as I can't reproduce this behaviour. There must be some other part of your application that causes it. Did you check at all if the thread count increases when you create the WriteableBitmap? – Clemens Nov 30 '13 at 21:19
  • I have checked before and after initializing wb using `Process.GetCurrentProcess().Threads.Count`. Before initializing wb I get 30 and right afterwards I get 31 so it looks like a thread is being created, but I honestly don't understand what for and how to deal with it. In addition why are there 30 threads running? – philkark Nov 30 '13 at 21:28
  • See [here](http://stackoverflow.com/a/1484365/1136211). – Clemens Nov 30 '13 at 21:47
  • Thank you, that answers the large thread count. But I have still no idea why initializing wb opens a new thread that remains after closing the window... – philkark Nov 30 '13 at 21:51
  • Even if a thread is created upon creation of a WriteableBitmap, that would not explain why terminating the application takes 15 seconds. – Clemens Nov 30 '13 at 22:03
  • I will look further where this problem might come from and post an answer if I find one. – philkark Nov 30 '13 at 22:07
  • WriteableBitmap does not directly create threads during construction; but, it does call into some native code during construction--who knows what happens in there... – Peter Ritchie Nov 30 '13 at 22:58
  • What about code that initializes values dimx, dimy, paletteGray? Creating any threads there? – Suresh Dec 01 '13 at 16:03
  • @sthotakura There is one possible problem I have found and I might update the question for that. I have many objects that each have one `WriteableBitmap` but they all use the same `paletteGray` so I only create it once being a static member and that might cause a problem. – philkark Dec 01 '13 at 16:08

0 Answers0