Interlocked.CompareExchange()

Aug 3, 2009 at 5:31 PM

Could someone tell me the consequences of replacing:

protected XmlUserStore Store {
            get {
                if (_store == null)
                    Interlocked.CompareExchange(
                        ref this._store,
                        new XmlUserStore(_fileName),
                        null);
                return _store;
            }
        }

with

protected XmlUserStore Store {
            get {
                if (_store == null) this._store = new XmlUserStore(_fileName);
                return _store;
            }
        }

I'm trying to make this application work with Grasshopper from Mainsoft (i.e. generate a Java war from this C# app), however it doesn't work if threading is involved (which is the case for Interlocked).

Thank you!

Eric Desgranges.

 

Coordinator
Aug 18, 2009 at 12:29 PM
Edited Aug 18, 2009 at 12:30 PM

Hi,

Shouldn't be a problem.
I will actually remove the Interlocked usage in next release, which is coming next couple of days, and will use a WeakReference for stores.

Regards