This project is read-only.

Hang issue when calling GatherWriterMetadata()

Nov 13, 2012 at 8:05 AM

Hi, I noticed a weird issue a couple of days ago where the GatherWriterMetadata() will hang indefinitely. I am assuming it is caused by a bad VSS service as I have noticed it happens on one of my colleagues machine but I failed to reproduce the case on mine. He runs a Win7 x86 Pro. This is the code I am using to create the snapshot set:

IVssImplementation _VssImpl = Alphaleonis.Win32.Vss.VssUtils.LoadImplementation(); 
IVssBackupComponents _VssBComp = _VssImpl.CreateVssBackupComponents();
_VssBComp.SetBackupState(false, true, Alphaleonis.Win32.Vss.VssBackupType.Full, false);
 using (Alphaleonis.Win32.Vss.IVssAsync async = _VssBComp.GatherWriterMetadata()) 
 async.Wait(); //---------> hangs 

I am looking for a way to abort the operation or set a timeout for it, thinking if my program is still waiting after 5 mins or so. Can I set a time out to IVssAsync ??

Nov 13, 2012 at 6:43 PM
Edited Nov 13, 2012 at 6:43 PM

Well, in the newer versions the BeginGatherWriterMetadata function returns an IVssAsyncResult that implements IAsyncResult. This means you can use the IAsyncResult.AsyncWaitHandle to wait for a specified period of time, and if a timeout occurs you can call the IVssAsyncResult.Cancel() method.