[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Backgroundworker and VSTO 2005 with C#

Backgroundworker and VSTO 2005 with C#

Juergen D.

11/29/2007 2:28:00 PM

Hi,
maybe somebody can help.
I added a Backgroundworker component to an Excel Spreadsheet because I have
to add data from this sheet to a database.
In the backgroundWorker_DoWork procedure I call the
backgroundWorker.ReportProgress regulary every 60 secods.
Inside my backgroundWorker_ProgressChanged function I have something like:

try {
Excel.Range r = Globals.Sheet1.Cells[1,1] as Excel.Range;
WriteToDatabase(r.Value2.ToString());
}
catch (Exception ex) {
WriteToLog(ex.ToString());
System.Threading.Thread.Sleep(100);
}

Everything works fine but Excel throws an Exception if it is busy and my
functions is reading the value from r.Value2. How can I check if it is safe
to access a cell? Is there something available like the InvokeRequired /
Invoke technique for working with UI Controls and background threads in
standard WinForm Applications?

Regards,
Juergen

Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Backgroundworker and VSTO 2005 with C#

Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te

Il servizio è completamente GRATUITO!