コード例 #1
0
ファイル: PinHandle.cs プロジェクト: studentutu/SharpUtils
 /// <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();
     }
 }
コード例 #2
0
 public static TField GetValueDirect <TField>(this FieldInfo fi, SafeReference sr)
 {
     return(sr.GetReference(tr => GetValueDirect <TField>(fi, tr)));
 }
コード例 #3
0
 public static void SetValueDirect <TField>(this FieldInfo fi, SafeReference sr, TField value)
 {
     sr.GetReference(tr => SetValueDirect <TField>(fi, tr, value));
 }
コード例 #4
0
 public static object GetValueDirect(this FieldInfo fi, SafeReference sr)
 {
     return(sr.GetReference(tr => fi.GetValueDirect(tr)));
 }
コード例 #5
0
 public static void SetValueDirect(this FieldInfo fi, SafeReference sr, object value)
 {
     sr.GetReference(tr => fi.SetValueDirect(tr, value));
 }