Implementing Excel 2003 COM Add-in UDF in Asyc Programming model using C#(VS 2005)

Posted by Venu on Stack Overflow See other posts from Stack Overflow or by Venu
Published on 2010-06-11T19:12:59Z Indexed on 2010/06/12 1:12 UTC
Read the original article Hit count: 311

Filed under:
|

Hi:

I am trying to implement a UDF using Excel COM Add-in(2003) with Visual Studio 2005 in C#. I would like to implement the UDF using async programming. The UDF is a slow operation as its results are fetched from a server.

As an illustration(not a real world example),the following UDF works fine without any issue:

 public double mul(double number1, double number2)
  {
     return number1 * number2;
  }

How can I do the same functionality in an async way: For example, I would like the UDF return immediately and later when the results are available from a server, I would like to update the desired cells.

 // This method returns immediately.
public object mul(double number1, double number2)
{
    return "calculating";
}


// This method of a worker thread will update the results.
public OnResultsAvailable(object result)
{

// Question: how should I update the cells that triggerred the calcualtions above?
}

Constraints: I cannot use Excel RTD as I have to work with existing codebase written using Excel C# COM Add-in.

Thanks for the help.

-Venu

© Stack Overflow or respective owner

Related posts about c#

Related posts about excel-2003