clickonce async wait

  • Thread starter Thread starter Chuck P
  • Start date Start date
C

Chuck P

I want to do an async update with clickonce.
The main reason is so I can get the

DeploymentProgressChangedEventArgs (bytes downloaded etc.)
and update the UI.

What is the best way to wait in the main thread until the

CheckForUpdateCompleted event fires.

thanks,
 
Hi Chuck,

Thank you for posting.

I think you could add code in the current ApplicationDeployment instance's
CheckForUpdateProgressChanged event handler to show the download progress
while waiting for the CheckForUpdateAsync operation completed.

Here is a link of an example you could refer to:
http://msdn2.microsoft.com/en-us/library/system.deployment.application.appli
cationdeployment.checkforupdatecompleted(VS.80,d=ide).aspx

Hope this is helpful to you.
If you have any other concerns or need anything else, please don't hesitate
to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Thanks, I was hoping to was to wait on the main thread until the
update is complete. Usually with threads you do this with
theUpdateThread.Join(). Which would wait until theUpdateThread
exited.

However, I don't know the thread(s) the ApplicationDeployment is
using.
 
Hi Chuck,

Thanks for your response.

It's hard to get the thread the ApplicationDeployment is using. However
since what you want to do is to wait in the main thread until the update is
completed, you could use the ManualResetEvent class do this.

ManualResetEvent class is designed to notify one or more waiting threads
that an event has occurred. There're Set and Reset methods in this class.
The Set method sets the state of the event to signaled, allowing one or
more waiting threads to proceed. The Reset method sets the state of the
event to nonsignaled, causing threads to block.

You could add an instance of the ManualResetEvent class in your program.
After you call ApplicationDeployment1.CheckForUpdateAsync, you could call
ManualResetEvent1.Reset to set the state of the event to nonsignaled. Then
in the ApplicationDeployment's CheckForUpdateCompleted event handler, you
may call ManualResetEvent1.Set to set the state of the event to signaled.

If you want to wait until the update is completed in main thread, you could
use ManualResetEvent1.WaitOne statement.

Hope this is helpful for you.
If you have any other concerns or need anything else, please don't hesitate
to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Back
Top