/// <summary> /// Pins a reference in a memory and constructs its pin handle. /// </summary> /// <param name="r">The reference to pin.</param> protected void ReferenceAction(SafeReference r) { using (var re1 = new AutoResetEvent(false)) { var thr = new Thread( delegate() { r.GetReference( //References are thread-unsafe! tr => { #if STORE_REFERENCE { SafeReference.Create( tr, r2 => { Reference = r2; re1.Set(); Reset.WaitOne(); } ); } #else { tr.Pin( delegate { re1.Set(); Reset.WaitOne(); } ); } #endif } ); } ); thr.Start(); re1.WaitOne(); } }
public static TField GetValueDirect <TField>(this FieldInfo fi, SafeReference sr) { return(sr.GetReference(tr => GetValueDirect <TField>(fi, tr))); }
public static void SetValueDirect <TField>(this FieldInfo fi, SafeReference sr, TField value) { sr.GetReference(tr => SetValueDirect <TField>(fi, tr, value)); }
public static object GetValueDirect(this FieldInfo fi, SafeReference sr) { return(sr.GetReference(tr => fi.GetValueDirect(tr))); }
public static void SetValueDirect(this FieldInfo fi, SafeReference sr, object value) { sr.GetReference(tr => fi.SetValueDirect(tr, value)); }