I have defined custom action to scan lan network computers. This action is declared as immediate and triggered after user click dialog button:
<CustomAction Id="actionGetNetworkComputers" BinaryKey="actionBinary" DllEntry="GetNetworkComputers" Execute="immediate" Return="check"/>
Custiom action code:
public static ActionResult GetNetworkComputers(Session session)
{
ListNetworkComputers.NetworkBrowser nb = new ListNetworkComputers.NetworkBrowser();
Microsoft.Deployment.WindowsInstaller.View lView = session.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='SERVER_LIST'");
lView.Execute();
lView = session.Database.OpenView("SELECT * FROM ComboBox");
lView.Execute();
int Index = 1;
try
{
foreach (string s in nb.getNetworkComputers())
{
Record lRecord = session.Database.CreateRecord(4);
lRecord.SetString(1, "SERVER_LIST");
lRecord.SetInteger(2, Index);
lRecord.SetString(3, s);
lRecord.SetString(4, s);
lView.Modify(ViewModifyMode.InsertTemporary, lRecord);
++Index;
}
}
catch (Exception ex)
{
session.Log(ex.StackTrace);
}
lView.Close();
return ActionResult.Success;
}
There are 2 main problems with this:
Action is blocking, so installer window freezes until nb.getNetworkComputers reurns. If I declare action return as asyncWait, action is executed but retrieved values are not inserted to ComboBox. Also, I need some label indicating operation progress, for example: "Scanning network, please wait" and hide this label after scan ends.
Is this possible with wix? Any tips?
I think the best way to go about this is to schedule the CA is Sync Check exit code and have your CA display it's own modal dialog with a cancel button telling you that a scan is in progress. Then use a BackgroundProcess class to spin your scan while checking to see if cancel was selected. When done ( for real or cancelled ) set a property for state and return sucess.
Then in your MSI Control Events you can check that property and either disallow transition to the next dialog or allow it ( mutually exclusive control event conditions ) based on your business rules.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.