[ExcelAsyncUtil] Change cell message #N/A to #calculating

Mar 18, 2013 at 10:17 AM
Hi All,

I'm new to Excel-Dna and I find it great !

I tried out this example

Asynchronous functions

I just wanted to know if there's an easy way to change "value error" to #wait message while waiting for calculation to finish.

Mar 18, 2013 at 11:20 AM

Sure - you should check the return value of ExcelAsyncUtil.Run(...) and if it is ExcelError.ExcelErrorNA then return your alternative:
        public static object SleepAsync(string ms)
            object runResult = ExcelAsyncUtil.Run("SleepAsync", ms, delegate
                Debug.Print("{1:HH:mm:ss.fff} Sleeping for {0} ms", ms, DateTime.Now);
                Debug.Print("{1:HH:mm:ss.fff} Done sleeping {0} ms", ms, DateTime.Now);
                return "Woke Up at " + DateTime.Now.ToString("1:HH:mm:ss.fff");
            if (runResult == ExcelError.ExcelErrorNA)
                return "#WAIT - BUSY";

            return runResult;

Mar 18, 2013 at 11:27 AM
Thanks. works great.