// -----------------------------------------------------------------------
        // KEY SAMPLE CODE STARTS HERE
        // -----------------------------------------------------------------------
        private async Task StabilizeVideo(string subscriptionKey, string originalFilePath)
        {
            _dataContext.IsWorking = true;
            _dataContext.SourceUri = null;
            _dataContext.ResultUri = null;

            Helpers.Log(LogIdentifier, "Start stabilizing");
            Microsoft.ProjectOxford.Video.VideoServiceClient client =
                new Microsoft.ProjectOxford.Video.VideoServiceClient(subscriptionKey);

            client.Timeout = TimeSpan.FromMinutes(10);

            using (FileStream originalStream = new FileStream(originalFilePath, FileMode.Open, FileAccess.Read))
            {
                // Creates a video operation of video stabilization
                Helpers.Log(LogIdentifier, "Start uploading video");
                Operation operation = await client.CreateOperationAsync(originalStream, new VideoStabilizationOperationSettings());
                Helpers.Log(LogIdentifier, "Uploading video done");

                // Starts querying service status
                OperationResult result = await client.GetOperationResultAsync(operation);
                while (result.Status != OperationStatus.Succeeded && result.Status != OperationStatus.Failed)
                {
                    Helpers.Log(LogIdentifier, "Server status: {0}, wait {1} seconds...", result.Status, QueryWaitTime.TotalSeconds);
                    await Task.Delay(QueryWaitTime);
                    result = await client.GetOperationResultAsync(operation);
                }
                Helpers.Log(LogIdentifier, "Finish processing with server status: " + result.Status);

                // Processing finished, checks result
                if (result.Status == OperationStatus.Succeeded)
                {
                    // Downloads generated video
                    string tmpFilePath = Path.GetTempFileName() + Path.GetExtension(originalFilePath);
                    Helpers.Log(LogIdentifier, "Start downloading result video");
                    using (Stream resultStream = await client.GetResultVideoAsync(result.ResourceLocation))
                    using (FileStream stream = new FileStream(tmpFilePath, FileMode.Create))
                    {
                        byte[] b = new byte[2048];
                        int length = 0;
                        while ((length = await resultStream.ReadAsync(b, 0, b.Length)) > 0)
                        {
                            await stream.WriteAsync(b, 0, length);
                        }
                    }
                    Helpers.Log(LogIdentifier, "Downloading result video done");

                    _dataContext.SourceUri = new Uri(originalFilePath);
                    _dataContext.ResultUri = new Uri(tmpFilePath);
                }
                else
                {
                    // Failed
                    Helpers.Log(LogIdentifier, "Fail reason: " + result.Message);
                }

                _dataContext.IsWorking = false;
            }
        }