list of t has 0 element after exit file

Shay Wilner 1,726 Reputation points
2020-05-17T19:39:17.773+00:00

Hi

I read a textfile and make some processing and get data in listtime when i check the listtime in the scope of the sub where i do processing ,listtime has N element but after exit the sub it has no element ?

 ![8220-im1.png][1]  

8325-im2.png

here the watch of the debugger
8392-watch1.png
8441-watch2.png

Thanks

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Shay Wilner 1,726 Reputation points
    2020-05-19T18:28:10.683+00:00

    Hi

    I don't succeed to achieve my goal

    8445-im1.png


2 additional answers

Sort by: Most helpful
  1. Xiaodi Yan 876 Reputation points MVP
    2020-05-22T22:36:39.64+00:00

    You need to use await for your async method. eg. await read-file()

    You also need to change MainPage_Loading() to an async method. If you don't use await for read-file(), you will hit the end of MainPage_Loading() before read-file() returns its result.

    Sorry because I cannot post "readfile" here so please use your method name to replace it.

    1 person found this answer helpful.
    0 comments No comments

  2. Peter Fleischer (former MVP) 19,231 Reputation points
    2020-05-18T03:53:18.713+00:00

    Hi, if you use await the execution of method ends before all instructions are executed. Try following code and check debug result in "Immediate Window". Use NotifyPropertyChanged to inform about the end of method.

    8404-x.png

    Another approach is to use LoadList as function:

    8370-x2.png

    0 comments No comments