This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
In this blog post, Karl Shifflet wraps repository calls to a dataservice inside TPL Tasks:
In LightSpeed, given a repository derived from Repository
Thanks. Vikram |
|
|
It potentially presents problems depending on the pattern of usage. If the idea is solely to allow loads to happen in the background, but loads will still be serialised, then you should be okay. Depending on the structure of your application -- for example, if the application kicks off a background load for each item in a collection -- you may need to introduce some explicit synchronisation or queuing to enforce serialisation. If the idea is to allow loads to happen in parallel, then you have a problem. The SimpleUnitOfWorkScope is not thread safe: your unit of work, and therefore your database connection, will end up being shared between tasks running concurrently on different threads, and you will soon see "connection is already in use" errors. |
|
|
Makes sense, thanks. Sounds like we need a ThreadSafeSerializingUnitOfWorkScope. Do you know if anyone has written something like that? Edit: I'm mainly interested in having loads and other LightSpeed operations happen on a background thread so that the UI remains responsive if something takes a while. Vikram |
|
|
No, sorry, I don't believe anyone has written anything like that. Given your fairly simple usage pattern it shouldn't be too tricky though -- let us know if you run into any problems! |
|