A
Aidal
Hi everyone.
I'm working on an add-in for Outlook 2007 (VS2005 with VSTO 2005 SE) in
which threading is required due to some actions taking a period of time to
finish and I don't want to freeze up my UI.
I have encountered a problem though, that I haven't seen before.
I've tried using the BackgroundWorker ("bgw" from now on) and also the
ExtendedBackgroundWorker found on Roy Osherove's Blog
(http://weblogs.asp.net/rosherove/pages/BackgroundWorkerEx.aspx) (nice work
by the way with the new cancel instantly feature) but the result is the same.
I can start to do work with the bgw just fine but once the bgw finishes it's
work and I wish to update my UI in some way, I get the "cross-thread action"
error.
This happens almost regardless of what I'm doing with the UI, even if I just
want to change .Enabled from false to true on a button.
There is one thing that I've seen not being affected though and that's a
PictureBox I'm using.
At first I tried to work with a progress bar, but the updating of it didn't
go down well, so I used one of these animated gifs that just shows that
"somthing is going on (well not really but it looks like it knows somthing).
So giving the PictureBox.Image the gif just before calling
bgw.RunWorkerAsync() and then setting the PictureBox.Image = null once the
bgw finished works (aka I can change this UI component without any errors)
but everything else on the UI I cannot touch once the bgw finishes...
Why is this and is there a solution to this problem out there?
(please don't tell me it's another of these sweet limitations)
Thanks,
/Aidal
I'm working on an add-in for Outlook 2007 (VS2005 with VSTO 2005 SE) in
which threading is required due to some actions taking a period of time to
finish and I don't want to freeze up my UI.
I have encountered a problem though, that I haven't seen before.
I've tried using the BackgroundWorker ("bgw" from now on) and also the
ExtendedBackgroundWorker found on Roy Osherove's Blog
(http://weblogs.asp.net/rosherove/pages/BackgroundWorkerEx.aspx) (nice work
by the way with the new cancel instantly feature) but the result is the same.
I can start to do work with the bgw just fine but once the bgw finishes it's
work and I wish to update my UI in some way, I get the "cross-thread action"
error.
This happens almost regardless of what I'm doing with the UI, even if I just
want to change .Enabled from false to true on a button.
There is one thing that I've seen not being affected though and that's a
PictureBox I'm using.
At first I tried to work with a progress bar, but the updating of it didn't
go down well, so I used one of these animated gifs that just shows that
"somthing is going on (well not really but it looks like it knows somthing).
So giving the PictureBox.Image the gif just before calling
bgw.RunWorkerAsync() and then setting the PictureBox.Image = null once the
bgw finished works (aka I can change this UI component without any errors)
but everything else on the UI I cannot touch once the bgw finishes...
Why is this and is there a solution to this problem out there?
(please don't tell me it's another of these sweet limitations)
Thanks,
/Aidal