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

Mar 18, 2013 at 11: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.

Thanks
Coordinator
Mar 18, 2013 at 12:20 PM
Hi,

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);
                Thread.Sleep(int.Parse(ms));
                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;

        }
-Govert
Mar 18, 2013 at 12:27 PM
Thanks. works great.