Due to a rather odd task, I'm wondering whether it is possible to create a Windows Service where, every x seconds we can create the PNG of a System.Windows.Control and write it to disk.
Currently, this process is handled via a WPF app for each user. The process works fine, however the rendering is slow (the controls are large and complicated), and several different versions need to be generated each time. With this in mind, I started wondering whether this could be handled server-side.
So, as an example, say we have a directory containing the following files:
- Test 1.txt
- Test 2.txt
- Test 3.txt
Every 5 seconds, I want to take the name of each of these files, generate a control with the filename as the content, and render to a PNG.
My attempts so far:
- Service using Timer: Fails with "The calling thread must be STA" even with [STAThread] plastered everywhere
- DispatcherTimer: Never ticks as there is no UI thread to cause it to tick
- Service using Timer and Application.Current.Dispatcher.Invoke: Will just crash as there is a null object or two in the call.
Does anyone know if this is even possible?