T
This_display_name_is_already_in_use_They_all_are
Guest
Original Text from WPF Forum: (Still relevant)
We have a Class, written in F# which is basically a FrameworkElement. Internal there is a VisualCollection which holds the rendered parts - for compositioning i guess.
The class itself represent a Graphic-To-Be-Rendered, which in this special case, has to be done without a UI thread and outside of a WPF application.
What we do is the following:
The file is empty but has the correct width & length.
I believe that it is not possible to do this without an App() or a WPF Context of some kind. We're kind of at a loss here.
Any Suggestions are welcome, since i've got nothing a the moment. The goal is basically to render something WPF into a FileStream from withing a thread inside a console application.
F# related addendum:
With combinding some of the solutions i got it working - but with a hack i cannot use in production. But at least now we know a little bit more about the Problem.
In F#, whenever we calculate stuff, we run
do! Async.SwitchToThreadPool()
When we are ready for actually drawing stuff, we run
do! Async.SwitchToContext guiSynchronizationContext
When debugging, i can get as far as to switching back to the UI Context, but there the execution stops - or the Debugger cannot hit any further breakpoint.
No Exception, no Debug output - nothing to work with. The rendered output is empty.
Now if we replace all the SwitchToThreadPool commands with SwitchToUIContext ones, the rendering suddenly starts working. Meaning that there is some kind of configuration issue that prevents us from reliably switching between the STA thread and the thread pool.
Continue reading...
We have a Class, written in F# which is basically a FrameworkElement. Internal there is a VisualCollection which holds the rendered parts - for compositioning i guess.
The class itself represent a Graphic-To-Be-Rendered, which in this special case, has to be done without a UI thread and outside of a WPF application.
What we do is the following:
- Spawn an STA Thread
- - Instantiate the Graphics
- - Populate with Data
- - Render to Bitmap
- - Return Synchronized stream
- Outside the STA Thread
- - Write stream to File
The file is empty but has the correct width & length.
I believe that it is not possible to do this without an App() or a WPF Context of some kind. We're kind of at a loss here.
Any Suggestions are welcome, since i've got nothing a the moment. The goal is basically to render something WPF into a FileStream from withing a thread inside a console application.
F# related addendum:
With combinding some of the solutions i got it working - but with a hack i cannot use in production. But at least now we know a little bit more about the Problem.
In F#, whenever we calculate stuff, we run
do! Async.SwitchToThreadPool()
When we are ready for actually drawing stuff, we run
do! Async.SwitchToContext guiSynchronizationContext
When debugging, i can get as far as to switching back to the UI Context, but there the execution stops - or the Debugger cannot hit any further breakpoint.
No Exception, no Debug output - nothing to work with. The rendered output is empty.
Now if we replace all the SwitchToThreadPool commands with SwitchToUIContext ones, the rendering suddenly starts working. Meaning that there is some kind of configuration issue that prevents us from reliably switching between the STA thread and the thread pool.
Continue reading...