Why am I getting so many non-crashing "A method was called at an unexpected time" exceptions?

0

It is scarcely exaggerating to say that I see more of these when my app runs:

Exception:Thrown: "A method was called at an unexpected time. (Exception from HRESULT: 0x8000000E)" 
(System.InvalidOperationException)
A System.InvalidOperationException was thrown: "A method was called at an unexpected time. (Exception 
from HRESULT: 0x8000000E)"
Time: 10/17/2014 9:18:21 PM
Thread:Worker Thread[7528]

...than I can stir a stone at.

After doing some research, I came to the conclusion, "I must have some async code that isn't using await"

But my only async code so far is:

private async void ConvertUserSelectionsToMapMarkers()
{
    FileOpenPicker openPicker = new FileOpenPicker();
    openPicker.ViewMode = PickerViewMode.Thumbnail;
    openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
    openPicker.FileTypeFilter.Add(".jpg");
    openPicker.FileTypeFilter.Add(".jpeg");
    openPicker.FileTypeFilter.Add(".png");
    List<PhotraxExifData> exifDataList = new List<PhotraxExifData>();

    IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();
    for (int i = 0; i < files.Count; i++)
    {
        using (var randomAccessStream = await files[i].OpenAsync(FileAccessMode.Read))
        {
            using (var stream = randomAccessStream.AsStream())
            {
                using (var exfrdr = new ExifReader(stream))
                . . .

I tried adding awaits to the last two usings, but they are not alowed in those instances.

Could it be the sqlite-net code? That is the only part of my project that has asyncs besides my code above.

Should I worry about it, since it's not seemingly causing a problem? Or is it an accident waiting to happen?

How does one know just where he should put "awaits"?

c#
windows-store-apps
async-await
asked on Stack Overflow Oct 19, 2014 by B. Clay Shannon • edited Oct 19, 2014 by dbc

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0