This is my first question here. I'm begining with XAML and C#, hope I can explain my problem and get some help. I'm afraid that my approach is not possible to implement, but maybe I could get some help with a workaround.
I need to print lots of cards. The process is running but freezes the main thread. I would like to do this bulk printing inside a BackgroundWorker and report progress in the main thread. I found some examples of how to do it and I created all the stuff necessary to run the backgroundworker.
The problem is that for each card, I create an stackpanel where I build the picture and finally print it using a FixedDocument and a printdialog.
Code crashes in the first line of the class accreditation_graphic
void m_oWorker_DoWork(object sender, DoWorkEventArgs e)
{
ObservableCollection<accreditation_field> _acc_list;
_acc_list = _param_acc_list;
accreditation_graphic _graphic = new accreditation_graphic();
// The sender is the BackgroundWorker object we need it to
// report progress and check for cancellation.
//NOTE : Never play with the UI thread here...
foreach (accreditation_field _acc in _acc_list)
{ [...] }
[...]
}
The class is:
class accreditation_graphic
{
private StackPanel _stack = new StackPanel();
public accreditation_graphic()
{
}
[...]
And the thread finishes with no error in: private StackPanel _stack = new StackPanel();
Is there any way to create an stackpanel in a backgroundworkers?
Thanks.