[Mono-list] Embedded api thread usage

Jonathan Mitchell lists at mugginsoft.com
Mon May 30 20:08:40 UTC 2016


I call my managed code via the embedded API and have hit a lock issue,.
The following statement gets called from my Objective C app’a main thread and from a managed worker thread.
Tracing seems to suggest that after the managed worker thread has accessed the lock the main C thread always fails to acquire the lock even after the managed thread has apparently exited the statement block. The lock is only used in this statement.

lock (SaveChangesLock) {
	value = base.SaveChanges(options);
}

If I replace the lock with Monitor.TryEnter  (SaveChangesLock) the lock is not acquired at first attempt but a subsequent attempt does succeed.

Is there anything I should be aware of here?
I am not quite sure how managed and native threads should interact.

Thanks

J




More information about the Mono-list mailing list