You don't need to have an immediate custom action. Here are some pointers.

1. The progress bar appears and is incremented during the deferred stage, so
any custom actions that run during this phase can update the bar. It's nice
to see some text that says what's happning when you control the progress
bar. For that, you'll need to add a new control to the built in WiX
ProgressDlg file (or create your own progress dialog from scratch). Add a
Text control that subscribes to ActionData. This will be what displays info
about your custom action as it's executing.

<Control Id="InfoText" Type="Text" X="50" Y="30" Width="200" Height="17">
     <Subscribe Event="ActionData" Attribute="Text" />
</Control>
<Control Id="ProgressBar" Type="ProgressBar" X="20" Y="115" Width="330"
Height="10" 
     ProgressBlocks="yes" Text="!(loc.ProgressDlgProgressBar)">
     <Subscribe Event="SetProgress" Attribute="Progress" />
</Control>

Now, to set what will be displayed in this Text control as your action is
running, add a ProgressText element inside the UI element. 

<ProgressText Action="DoStuff" Template="DoStuff is executing: [1]" />

The Action attribute is the name of your custom action (it's Id). The
Template is what will show. The [1] will be replaced by text you set in your
custom action. So, you can give mini-updates throughout a single custom
action.

To reset the progress bar to zero at the start of your action, make a
function that calls the Session.Message method with the right attributes:

private static void ResetProgress(Session session)
{
     Record record = new Record(4);
     record[1] = "0";
     record[2] = "1000";
     record[3] = "0";
     record[4] = "0";
     session.Message(InstallMessage.Progress, record);
}

The first key, when set to 0, tells the progress bar to reset itself. The
second key says how many ticks total it should have in the bar. Now, add a
function that will increment the bar every time you post another actiondata
message a certain number of ticks.

private static void NumberOfTicksPerActionData(Session session, int ticks)
{
     Record record = new Record(3);
     record[1] = "1";
     record[2] = ticks.ToString();
     record[3] = "1";
     session.Message(InstallMessage.Progress, record);
}

The first and third keys here are "1" and the second is the number of ticks
to increment each time. Next, add a method that will post an actiondata
message.

private static void DisplayActionData(Session session, string message)
{
     Record record = new Record(1);
     record[1] = message;
     session.Message(InstallMessage.ActionData, record);
}

Now in your custom action, you can post updates to the progress bar that
will display new text over it and add some ticks. Such as:

[CustomAction]
public static ActionResult DoStuff(Session session)
{
     ResetProgress(session);
     NumberOfTicksPerActionData(session, 100);
     DisplayActionData(session, "This is my first message");
     System.Threading.Thread.Sleep(2000);
     DisplayActionData(session, "This is my second message");
     System.Threading.Thread.Sleep(2000);
     DisplayActionData(session, "This is my third message");
     System.Threading.Thread.Sleep(2000);
     return ActionResult.Success;
}
-- 
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Show-the-ProgressBar-while-Running-the-Custom-Action-tp5078136p5085924.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------

_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to