Note that there are some explanatory texts on larger screens.

plurals
  1. POVici coolstorage additional threads
    primarykey
    data
    text
    <p>I have a relatively small project on monotouch for iPhone &amp; Android with plans to add WP7. I use vici coolstorage as an ORM on SQLite, and it works fine for me, but there is one issue. It creates additional threads per thread using db. I already hit the limit of threads as the application is massively parallel, so I want to change it. I found out that thread creation is performed in CSConfig.cs where for <em>each</em> call to GetDB from different thread a new thread is created:</p> <pre><code> internal static CSDataProvider GetDB(string strContext) { if (_threadData == null) _threadData = new ThreadData(); return _threadData.GetDB(strContext); } </code></pre> <p>The <code>_threadData</code> is marked <code>[ThreadStatic]</code>. I suppose this GetDB is called each time I use the ORM (I set default DB in CSConfig to my DB). The thread is created inside <code>ThreadData</code> constructor. And the thread executes this function:</p> <pre><code> private void CleanupBehind() { _callingThread.Join(); foreach (CSDataProvider db in _threadDbMap.Values) db.Dispose(); } </code></pre> <p>So, essentially it waits for the caller to terminate and then disposes database connection.</p> <p>The question is, how can I override this behavior and either let GC dispose the database connections or call the <code>Dispose()</code> myself before the calling thread terminates (I control all the threads using DB, so I can do it). I know it is not good not to let the ORM handle disconnection when the thread ends, but I can not work with one additional thread per worker thread.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload