Hi Norbert and Henrik,
It is usually recommended to have one context per thread. The examples you have seen focus on this approach. The context is intended to be a light-weight object so if you have multiple threads each thread is recommended to interact with its own context. As Henrik pointed out in order to load data asynchronously you will need a different thread to load the data. The thread can be simply a background worker for example. There are some considerations to be made before deciding on whether you will have one context for both the main thread and the data-loading thread or you will have separate ones. If you will not modify the data you will be displaying then we would suggest that you use the context-per-thread approach. If, however, you need to perform updates on the data you will be showing in the grid, then you should opt for the single context initialized in the main thread and passed to the data-loading thread. The second solution is basically what Henrik suggested. You should be careful, though, because you will have to set the multithreading option for the context you use. In order to do so, you may open the Model Settings Dialog
and in the Backend Settings -> Runtime Settings
tab check the Multithreaded Context
option. Do not forget the handle the disposal of the context when the main thread's life ends.
Do not hesitate to contact us, should you have further questions.
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat
for a walk through all the exciting stuff we ship with the new release!