Windows Azure Platform > Azure Forums > Live Framework > When to use IsLoaded and Load()
Ask a questionAsk a question
 

AnswerWhen to use IsLoaded and Load()

  • Sunday, February 15, 2009 6:43 PMMatthiasJa Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello Live,

    Currently I'm making my mind up about the IsLoaded property on the different LiveItem classes and when I have to call the Load() method to get the various exposed Resources. At the moment I'm checking IsLoaded everytime I want to access LiveItem's, but I wonder why/if I have to...
    The following questions are for S/MEWAs:
    • First I've loaded the MeshApplicationService with the Load() method on it. Is this loading everything or have I to load the DataFeeds and their DataEntries separately? Is there a need to check with IsLoaded?
    • Same question for other LiveItem's like Mappings, News or Devices. Do I have to check with IsLoaded after running MeshApplicationService.Load()?
    • Last but not least: if I receive a change notification on a data feed, how to get the new (changed) data entries? Is it ok just to call myDataFeed.Load() or do I have to call myDataFeed.DataEntries.Load() additionally? Or is the load of the data entries included in the load of the data feed?

    Thanks a lot,
    Matthias

Answers

  • Monday, February 16, 2009 7:10 AMYi-Lun LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    1. When you call MeshApplicationService.Load(Async), only the MeshObject that representing your MEWA will be loaded. This is reasonable since your application may have tons of DataFeed/Entry, and you do not want to download all of them when the application starts.


    You don't need to check IsLoaded if you're using the Load method, since you're performing a synchronous operation. When using LoadAsync (recommended since you don't want to freeze the browser), you need to check IsLoaded. For example, when the user clicks a Button, if the MeshApplicationService hasn't been loaded, you may be in trouble. Another solution is to handle LoadCompleted event. At first you disable all Buttons in the application. In this event handler, you enable them. Thus you don't need to check IsLoaded in every event handler.


    2. As mentioned before, simply load the MeshApplicationService will not load items such as mappings and news. In order to download the data, you need to create queries on those resources, or access properties such as MeshApplicationService.Mappings. You don't need to call Load on anything.


    3. We have found some problems in change notification. When you run the MEWA from the Live Desktop, your browser may be frozen... Our product team is working on a fix. Before the fix is ready, please do not use change notification in a Silverlight MEWA. If you're working on desktop applications, we've also found some problems with change notification, in which you won't be able to find the new object in the notification callback when you work with the local MOE. Currently it is recommended to create a new query in the callback. In the future, the problems will be fixed. And the above rules still apply to this scenario. You don't need to call the Load method. But initially not all data is downloaded. When you access the DataEntries property or make queries, web requests will be made to get the data.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked As Answer byMatthiasJa Monday, February 16, 2009 9:48 AM
    •  

All Replies

  • Monday, February 16, 2009 7:10 AMYi-Lun LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    1. When you call MeshApplicationService.Load(Async), only the MeshObject that representing your MEWA will be loaded. This is reasonable since your application may have tons of DataFeed/Entry, and you do not want to download all of them when the application starts.


    You don't need to check IsLoaded if you're using the Load method, since you're performing a synchronous operation. When using LoadAsync (recommended since you don't want to freeze the browser), you need to check IsLoaded. For example, when the user clicks a Button, if the MeshApplicationService hasn't been loaded, you may be in trouble. Another solution is to handle LoadCompleted event. At first you disable all Buttons in the application. In this event handler, you enable them. Thus you don't need to check IsLoaded in every event handler.


    2. As mentioned before, simply load the MeshApplicationService will not load items such as mappings and news. In order to download the data, you need to create queries on those resources, or access properties such as MeshApplicationService.Mappings. You don't need to call Load on anything.


    3. We have found some problems in change notification. When you run the MEWA from the Live Desktop, your browser may be frozen... Our product team is working on a fix. Before the fix is ready, please do not use change notification in a Silverlight MEWA. If you're working on desktop applications, we've also found some problems with change notification, in which you won't be able to find the new object in the notification callback when you work with the local MOE. Currently it is recommended to create a new query in the callback. In the future, the problems will be fixed. And the above rules still apply to this scenario. You don't need to call the Load method. But initially not all data is downloaded. When you access the DataEntries property or make queries, web requests will be made to get the data.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked As Answer byMatthiasJa Monday, February 16, 2009 9:48 AM
    •  
  • Monday, February 16, 2009 7:30 AMMatthiasJa Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello Yi-Lun,

    So I've never to check IsLoaded and to call Load()? It's all done automatically if I query anything, right?
    I've found that I can get updated data if I call Load() when receiving a change notification. I know the freezing issues, but this works well for running the S/MEWA locally. I found out that if I don't call dataFeed.DataEntries.Load(), then I don't get the updated data.


    ~ Matthias
  • Monday, February 16, 2009 7:36 AMYi-Lun LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, calling Load in the change notification callback will also help if you have a reference to the DataFeed.  The Load method will update your in memory data with the latest data from LOE. When working with queries, you don't need to call the Load method.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.