locked
ContextSwitchDeadlock while using SyncToyEngine RRS feed

  • Question

  • Hi all, for some reasons I'm writing a component that will be used to synchronized the content of two folders.

    I started this project by using the logic of SyncToy, exactly using the "SyncToyEngine.dll" file.

    I'm at the beginning so the code is very simple and basic but I started this way.

    I created my SyncEngineConfig object and used it to create the SyncEngine.


    private SyncToy.SyncEngineConfig _sec;
    
    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
    StreamReader sr = new StreamReader("C:/Users/.../SyncToyDirPairs.bin");
    _sec = (SyncToy.SyncEngineConfig)bf.Deserialize(sr.BaseStream);
    SyncToy.SyncEngine engine = new SyncToy.SyncEngine(_sec);
    engine.Preview();

    At this point I get an exception:

    ContextSwitchDeadlock was detected
    Message: The CLR has been unable to transition from COM context 0x14cfd0 to COM context 0x14d140 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.


    Why?Any idea?




    Monday, February 8, 2010 6:20 PM

Answers

  • Hi -

    I realize that we have public classes in SyncToyEngine.dll that lets you initialize the classes that you need. But this is unsupported. If you want to reuse the logic of SyncToy - the correct place to hook in is the File Sync Provider. Take a look at the documentation below - everything SyncToy does can be accomplished using the File Sync Provider.

    http://msdn.microsoft.com/en-us/library/bb902860(SQL.105).aspx

    Thanks
    Deepa

    Deepa ( Microsoft Sync Framework)
    Tuesday, February 9, 2010 8:05 PM