0

Okay so I'm making an app for windows 8 store, but I'm using MessageDialog for errors I'm not particularly sure why but it seems that when I include the MessageDialog the foreach loop stops looping through every single line and looking at the first line only, so here's my code;

try {
    StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
    StorageFile storageFile = await folder.GetFileAsync("students.txt");
    var text = await Windows.Storage.FileIO.ReadLinesAsync(storageFile);

    foreach (var line in text)
    {
        string name = "" + line.Split('|')[0];
        string testTaken = "" + line.Split('|')[1];

        if (your_name.Text == name)
        {
            if (testTaken == "false") 
            {
                pageTitle.Text = name + "'s test";
                enter_name_grid.Opacity = 0;
                questions_grid.Opacity = 1;
                var md = new MessageDialog("Enjoy the test");
                await md.ShowAsync();
            }
            else
            {
                var md1 = new MessageDialog("You have already taken the test");
                await md1.ShowAsync();
            }
        }
        else
        {
            pageTitle.Text = "Test";
            var md2 = new MessageDialog("You're not on the list");
            await md2.ShowAsync();
        }
    }
} catch (Exception e) {
    var mderror = new MessageDialog("{0} Exception caught: " + e);
    mderror.ShowAsync();
}

I have really hit a dead end with this now so anyone that can shed some light or give any help, it would be appreciated! thanks

user3263978
  • 193
  • 1
  • 2
  • 14
  • Just as a sidenote, it WAS working before when using inline error messages (showing the error on the actual app itself) – user3263978 Apr 07 '14 at 20:28
  • isn't your messageDialog modal? isn't it blocking execution similar to any messagebox would? – T McKeown Apr 07 '14 at 20:30
  • @TMcKeown is there any possible way around this? – user3263978 Apr 07 '14 at 20:35
  • yes, it depends on how you want to handle it... if you find this issue should you set a msg variable, `break` out of foreach and then display message there? You have to determine this.. – T McKeown Apr 07 '14 at 20:38

0 Answers0