locked
Is there any way to abort a Sync process once Synchronize is called? RRS feed

  • Question

  •  

    As per the title.  Apart from killing the thread that the process is running on, is there any way to interrupt a long running Synchronization?

     

    Thanks.

    Glen

    • Moved by Max Wang_1983 Friday, April 22, 2011 8:42 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, February 12, 2008 1:55 PM

Answers

  • I have consulted with a number of sync experts on this topic and the common advice is - have the synchronization process work on a working thread/process so the parent one (or the monitor one) can terminate it.

     

    Thanks

     

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, February 14, 2008 6:06 PM
    Answerer

All replies

  • Can you provide more details in your scenario?

     

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, February 12, 2008 3:23 PM
    Answerer
  • Hi,

    I haven't tried this myself yet, but I did come accross the Cancel method on the Sync Agent class:
    http://msdn2.microsoft.com/en-us/library/microsoft.synchronization.syncagent.cancel(SQL.100).aspx

    That should be what you are looking for. The question of course is how the cancel works inside. It could stop the provider threads instantly by aborting them or more probably wait for one of the provider methods to return and then cancel all work from then on. The latter would lead to long running provider methods (such as change batch enumeration) not being able to be cancelled, but you could cancel the actual data transfer phase. I haven't found a way to check for the cancel while implementing my own provider, so I think the Microsoft own providers won't have that option either (but that's pure speculation on my behalf).

    hth,
    Alex
    Tuesday, February 12, 2008 4:49 PM
  • Thanks very much Alex, I'll look into that and have a play..

     

    As for my scenario - well I guess it would be a common one...  I want to give the user the option of cancelling the process and synching later... there could be a multitude of reasons why. 

     

    Thanks.

     

    Glen

    Tuesday, February 12, 2008 8:28 PM
  • Hi Glen,

    I too see a definate use for stopping a sync operation. An application I am working on at the moment uses remotely connected users on 3G mobile wireless network to connect to and syncronize with the main server. In this scenario if there is a poor connection the user could abort and try again when the connection is better to save excessively long download times.

     

    I am glad you brought it, I was not sure how I would handle this scenario, but now I have a option of Alex's to explore.  

     

    Regards

     

    Brett

     

    Wednesday, February 13, 2008 10:54 PM
  • I have consulted with a number of sync experts on this topic and the common advice is - have the synchronization process work on a working thread/process so the parent one (or the monitor one) can terminate it.

     

    Thanks

     

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, February 14, 2008 6:06 PM
    Answerer
  • Still the question remains how to terminate it.Brute force killing the thread should only be the last resort I think.

    an idea for the team on this same topic:
    For those who implement custom providers it would be helpful to get access to the corresponding state of the syncagent or sync session to be able to check for cancellation in long-running methods of the provider implementation. Currently I haven't found a reference to the sync agent from the provider and the session context object does not have a suitable property either.

    just my two cents,
    Alex
    Tuesday, February 19, 2008 9:09 PM