Microsoft Synchronisation Framework

Microsoft is soon to be releasing their Synchronisation Framework. To some people, it’s Microsoft’s answer to Google Gears, but I would have to disagree with them. Simply assessing the two technologies as being like for like misses some fairly fundamental points.

  1.  Google Gears is aimed at extending Internet applications onto the desktop. In other words, you can run some fairly sophisticated applications in a browser and have them interact as though they are desktop based. I say appear here because they run in some fairly tight restrictions, such as they are sandboxed. Plus, there is a certain lack of control for the user – where is their data stored, offline, online or some weird combination of the two? Effectively, you can think of Gears as being local storage for web applications.
  2. Sync Framework is designed to work the other way round. It’s a desktop based technology so it can run from the desktop up to the server.
  3. Sync Framework extends from synchronising items such as folders, emails, databases or pretty much anything else you can think of.

In this example, you can see how easy it is to synchronize file changes.

public void SyncFiles(SyncId sync, SyncId destinationId, string sourceRoot, string destRoot, 
  FileSyncScopeFilter filter, FileSyncOptions options 
{ 
  using (FileSyncProvider source = new FileSyncProvider(sync, sourceRoot, 
      filter, options)) 
  { 
    using (FileSyncProvider destination = FileSyncProvider(destinationId, destRoot, 
       filter, options)) 
    { 
      destination.AppliedChange += new EventHandler<AppliedChangeEventArgs>(OnApplyChange); 
      SyncAgent agent = new SyncAgent(); 
      agent.LocalProvider = source; 
      agent.RemoteProvider = destination; 
      agent.Direction = SyncDirection.Upload; 
      agent.Synchronize(); 
    } 
  } 
}  public void OnApplyChange(object sender, AppliedChangeEventArgs args) 
{ 
  if (args.ChangeType == ChangeType.Create) 
    Console.WriteLine("The file {0} has been moved to {1}", 
      args.OldFilePath, args.NewFilePath); 
}

As you can see, synchronising the files is very simple indeed. This level of functionality is available for database content as well. I look forward to its release.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s