locked
Sharing failed when running in none-debug mode

    Question

  •  app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                	var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
                	dataTransferManager.addEventListener("datarequested", function (e) {
                		var request = e.request;
                		request.data.properties.title = "Share Image Example";
                		request.data.properties.description = "A demonstration that shows how to share an image.";
                		var deferral = request.getDeferral();
                		Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("images\\smalllogo.png").then(function (thumbnailFile) {
                			request.data.properties.thumbnail = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(thumbnailFile);
                			return Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("images\\logo.png");
                		}).done(function (imageFile) {						
                			setTimeout(function () {
                				request.data.setBitmap(Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile));
                				deferral.complete();
                			}, 1000);
                			
                		}, function (err) {
                			request.failWithDisplayText(err);
                		});;
                	});
                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
                args.setPromise(WinJS.UI.processAll());
            }
        };

    The above codes actually came from the example from Microsoft. I just added a "setTimeout" call to simulate my scenario. In my scenario, I need to do a lot of works to prepare the data for sharing, it is quite often to take more than 200 ms to complete them.

    The codes worked well in debug mode(launch from VS), while got an error ("App can't share right now, run again later") in normal mode (launch from start screen).

    It looks like there is a "Timeout" mechanism there, is it? 

    Any suggestions are welcome, and thanks in advance.

    cheers

    Alex


    woodhead is as woodhead does

    Tuesday, July 3, 2012 2:17 AM

Answers

All replies