winforms - custom windows form on uninstall -


i want show custom windows form on uninstall. going use c# custom action this. how make custom action wait till user clicks ok or cancel? want custom action complete when form closed. following in custom action:

    collectuninstalldata f = new collectuninstalldata();             f.show();             return f.formresult; 

but form blinks moment , uninstall continues without waiting form close. , logical since gui in thread. how make wait form close?

i aware showing custom windows forms in install packages isn't cool, if can offer more elegant solution, thankfully accept it.

you have use showdialog() method instead of show(). latter makes form visible , returns control that's why custom action stops execution. former shows form modal dialog box , not return until user closes form in way.

collectuninstalldata f = new collectuninstalldata(); dialogresult r = f.showdialog(); f.dispose();  return r; 

if want know whether user clicked ok or cancel, use statement return r == dialogresult.ok ? 0 : 1. return code of 0 indicates success , non-zero failure.


Comments