xsharp.eu • How to 'await' the result of a .Net routine called from VO?
Page 1 of 1

How to 'await' the result of a .Net routine called from VO?

Posted: Tue May 04, 2021 9:38 pm
by ic2
I have created a WPF window which can import Excel sheets into a DBF using Microsoft.Office.Interop.Excel. This is all done in my DotNet DLL containing X# and C# routines and called like this:

oDotNet:= OLEAutoObject{"DotNetLibForVO.VoDotNetClass"}
IF oDotNet:Finit
// assign some parameters
oDotNet:ShowExcelWin(cPathExt,cFileExt,cHeadersExt,cTypesExt)
ENDIF
// What happens next should wait but it doesn't

The problem is that everything which happens in that Excel window works like a ASYNC call, or a modeless window, and the VO code continues once it has started the ShowExcelWin in X#. But I want the program to be able to find out if the Excel import has been finalized.

I can use a simple trick of course, like creating a file or something, but is there a more advanced way to let VO await the finalizing of the ExcelImport window from the X# DLL?

EDIT: seconds after I posted it, I found the solution (for this situation at least): I can use ShowDialog instead of Show for a WPF window. But I am still interested in other solution, not involving windows but still with the need to await the result.

Dick