コード例 #1
0
        private void Execute(SandboxLoader loader, PendingAction action)
        {
            try
            {
                switch (action.Type)
                {
                case PendingActionType.CreateOrUpdate:
                    loader.CreateOrUpdate(action.Path);
                    break;

                case PendingActionType.Remove:
                    loader.Delete(action.Path);
                    break;

                case PendingActionType.Reload:
                    foreach (string file in Directory.EnumerateFiles(action.Path, "*.csproj", SearchOption.AllDirectories))
                    {
                        _pendingActions.Enqueue(PendingAction.CreateOrUpdate(file));
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                // We should retry operations for certain failures because
                // changes are the operation will succeed the next time.
                // Reasons are:
                // - The file is currently owned by another process
                // - The file is being modified and not yet ready to be consumed
                // - Some other related race condition occured that will likely be remedied in the future
                // Algorithm:
                // Exponential backoff with a fixed upper limit of tries.
                // TODO: Implement!

                Log.ErrorFormat("Caught unexpected exception while executing '{0}': {1}",
                                action,
                                e);
            }
        }
コード例 #2
0
 private void OnRenamed(object sender, RenamedEventArgs e)
 {
     _pendingActions.Enqueue(PendingAction.CreateOrUpdate(e.Name));
 }
コード例 #3
0
 private void OnChanged(object sender, FileSystemEventArgs e)
 {
     _pendingActions.Enqueue(PendingAction.CreateOrUpdate(e.Name));
 }