Esempio n. 1
0
 public Boolean WriteScoop(int scoop, long totalNonces, long startNonce, Scoop source, int limit)
 {
     _lPosition = scoop * (64 * totalNonces) + startNonce * 64;
     try
     {
         _ft.Seek(_lPosition, SeekOrigin.Begin);
     }
     catch (Exception e)
     {
         MessageBox.Show("Scoop: " + scoop.ToString() + " " + e.Message, "I/O Error - Seek to write", MessageBoxButtons.OK);
         return(false);
     }
     try {
         //interrupt avoider 1mb read 64*16384
         for (int i = 0; i < limit * 64; i += (64 * 16384))
         {
             _ft.Write(source.byteArrayField, i, Math.Min(64 * 16384, limit * 64 - i));
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Scoop: " + scoop.ToString() + " " + e.Message, "I/O Error - Write", MessageBoxButtons.OK);
         return(false);
     }
     _lPosition += limit * 64;
     return(true);
 }
 public Boolean ReadScoop(int scoop, long totalNonces, long startNonce, Scoop target, int limit)
 {
     _lPosition = scoop * (64 * totalNonces) + startNonce * 64;
     try {
         _fs.Seek(_lPosition, SeekOrigin.Begin);
     }
     catch (Exception e)
     {
         MessageBox.Show("Scoop: " + scoop.ToString() + " " + e.Message, "I/O Error - Seek to read", MessageBoxButtons.OK);
         return(false);
     }
     try {
         _fs.Read(target.byteArrayField, 0, limit * 64);
     }
     catch (Exception e)
     {
         MessageBox.Show("Scoop: " + scoop.ToString() + " " + e.Message, "I/O Error - Read", MessageBoxButtons.OK);
         return(false);
     }
     _lPosition += limit * 64;
     return(true);
 }