excel ribbon becoming unresponsive

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Hi,
I am trying to create an add-in for Excel using Visual Studio Tools
for Office. I have added some buttons to ribbon. Upon clicking one,
I launch another application that interacts with excel. But for some
reason after doing that the Excel sheet is no longer responsive to
clicks of the button ribbons. Anyone have any ideas of what could be
wrong?

Thanks,
Bob
 
It is just a wild guess since I haven't done anything with add-in's so
far. Could it be that that your button starts this other process and
waits for its completion? If so then my guess is that the thread that
your button is in may be still waiting for the other process to finish
hence the blocking UI. Maybe you could try to start the other process
in a separate thread to get around this, but maybe this also makes
things too complicated.

Greets
Frank
 
It is just a wild guess since I haven't done anything with add-in's so
far. Could it be that that your button starts this other process and
waits for its completion? If so then my guess is that the thread that
your button is in may be still waiting for the other process to finish
hence the blocking UI. Maybe you could try to start the other process
in a separate thread to get around this, but maybe this also makes
things too complicated.

Greets
Frank


I think that might be it but when I try to use a ThreadStart to start
in a different thread the application I am trying to run seems to
crash. Is this the right way to do it:


Launcher useForLaunch = new Launcher();

useForLaunch.excelObj = excelObj;

System.Threading.Thread oThread = new System.Threading.Thread(new
System.Threading.ThreadStart(useForLaunch.Launch));
oThread.Start();

public class Launcher{

internal Microsoft.Office.Interop.Excel.Application
excelObj;
internal void Launch()
{

ExternalInterface fInt2 = new ExternalInterface(excelObj);
}
}

Thanks!
Bob
 
Hmm, I have only used the "BackgroundWorker" classes present
since .Net 2.0.
The documentation has some pretty good example how to set them up but
basically its like creating a BackgroundWorker object, writing at
least one eventhandler for the DoWork event and one for the
RunWorkerCompleted event. Any Exception inside the background thread
will end the thread and you end up inside the RunWorkerCompleted
handler.


In your case this would look like
BackgroundWorker imyworker = new BackgroundWorker();
// then add the event handlers to the DoWork and RunWorkerCompleted
events and finally call imyworker.RunWorkerAsync() and off it goes.

void imyworker_DoWork(object sender, DoWorkEventArgs e)
{
//maybe some other init stuff here
useForLauncher.Launch();
}
void imyworker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
if (e.Error != null) // an exception occurred, e.Error contains the
exception object
//maybe some other cleanup code, message, log entry etc.
}

Maybe the exception that you get tells you what's going wrong

Greets
Frank
 
Hmm, I have only used the "BackgroundWorker" classes present
since .Net 2.0.
The documentation has some pretty good example how to set them up but
basically its like creating a BackgroundWorker object, writing at
least one eventhandler for the DoWork event and one for the
RunWorkerCompleted event. Any Exception inside the background thread
will end the thread and you end up inside the RunWorkerCompleted
handler.

In your case this would look like
BackgroundWorker imyworker = new BackgroundWorker();
// then add the event handlers to the DoWork and RunWorkerCompleted
events and finally call imyworker.RunWorkerAsync() and off it goes.

        void imyworker_DoWork(object sender, DoWorkEventArgs e)
        {
                //maybe some other init stuff here
                useForLauncher.Launch();
        }
        void imyworker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
        {
                if (e.Error != null)  // an exceptionoccurred, e.Error contains the
exception object
                //maybe some other cleanup code, message,log entry etc.
        }

Maybe the exception that you get tells you what's going wrong

Greets
Frank

Thanks for the very thoughtful post. I don't think a background
worker will work because the process I want to start is itself a a
gui. Not getting an exception in the c#, the excel instance crashes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top