本文整理汇总了C#中Future.GetResult方法的典型用法代码示例。如果您正苦于以下问题:C# Future.GetResult方法的具体用法?C# Future.GetResult怎么用?C# Future.GetResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Future
的用法示例。
在下文中一共展示了Future.GetResult方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetResultMethodNeverThrows
public void TestGetResultMethodNeverThrows () {
var f = new Future<object>();
object result;
Exception error;
Assert.IsFalse(f.GetResult(out result, out error));
f.SetResult(5, null);
Assert.IsTrue(f.GetResult(out result, out error));
Assert.AreEqual(5, result);
f = new Future<object>();
f.SetResult(null, new Exception("earth-shattering kaboom"));
Assert.IsTrue(f.GetResult(out result, out error));
Assert.IsTrue(error is Exception);
}
示例2: Dispose
private void Dispose (bool disposing)
{
// TODO: Review command disposing
/*
if (disposing)
{
CloseCursor ();
}
*/
Future future = new Future (Service.FreeStmt, GetId (), (int) CLI.FreeStmtOption.SQL_DROP);
try
{
connection.futures.Add (future);
future.SendRequest (connection.Session);
future.GetResult (connection.Session, connection.futures);
}
finally
{
connection.futures.Remove (future);
}
}
示例3: Cancel
public void Cancel ()
{
Future future = new Future (Service.FreeStmt, GetId (), (int) CLI.FreeStmtOption.SQL_CLOSE);
try
{
connection.futures.Add (future);
future.SendRequest (connection.Session);
future.GetResult (connection.Session, connection.futures);
}
finally
{
connection.futures.Remove (future);
}
}
示例4: GetData
private long GetData (ColumnData column, BlobHandle blob, int length, object buffer, int bufferOffset)
{
Debug.WriteLineIf (CLI.FnTrace.Enabled, "ManagedCommand.GetData()");
Future future = new Future (Service.GetData,
blob.current_page,
length,
blob.current_position,
blob.keyId,
blob.fragNo,
blob.dirPage,
blob.pages,
blob.tag == BoxTag.DV_BLOB_WIDE_HANDLE ? 1 : 0,
blob.timeStamp);
object result = null;
try
{
connection.futures.Add (future);
future.SendRequest (connection.Session, timeout);
result = future.GetResult (connection.Session, connection.futures);
}
finally
{
connection.futures.Remove (future);
}
if (!(result is object[]))
return 0;
object[] results = (object[]) result;
if (results[0] is int && (AnswerTag) results[0] == AnswerTag.QA_ERROR)
{
errors.AddServerError ((string) results[1], null, (string) results[2]);
Diagnostics.HandleResult (CLI.ReturnCode.SQL_ERROR, this, connection.OuterConnection);
}
int startOffset = column.lobOffset;
for (int i = 0; i < results.Length; i++)
{
if (results[i] is int[])
{
int[] array = (int[]) results[i];
blob.current_page = array[1];
blob.current_position = array[2];
continue;
}
else if (results[i] is string)
{
string s = (string) results[i];
if (buffer is char[])
{
char[] chars = s.ToCharArray ();
char[] charBuffer = (char[]) buffer;
Debug.WriteLineIf (Switch.Enabled, "do chars");
Debug.WriteLineIf (Switch.Enabled, "buffer length: " +
(charBuffer == null ? "no" : charBuffer.Length.ToString ()));
Debug.WriteLineIf (Switch.Enabled, "buffer offset: " + bufferOffset);
Debug.WriteLineIf (Switch.Enabled, "data length: " + chars.Length);
Debug.WriteLineIf (Switch.Enabled, "length: " + length);
if (charBuffer != null)
{
int copyLength = length < chars.Length ? length : chars.Length;
Array.Copy (chars, 0, charBuffer, bufferOffset, copyLength);
}
column.lobOffset += chars.Length;
bufferOffset += chars.Length;
length -= chars.Length;
}
else
{
byte[] bytes = Encoding.GetEncoding ("iso-8859-1").GetBytes (s);
byte[] byteBuffer = (byte[]) buffer;
Debug.WriteLineIf (Switch.Enabled, "do bytes");
Debug.WriteLineIf (Switch.Enabled, "buffer length: " +
(byteBuffer == null ? "no" : byteBuffer.Length.ToString ()));
Debug.WriteLineIf (Switch.Enabled, "buffer offset: " + bufferOffset);
Debug.WriteLineIf (Switch.Enabled, "data length: " + bytes.Length);
Debug.WriteLineIf (Switch.Enabled, "length: " + length);
if (byteBuffer != null)
{
int copyLength = length < bytes.Length ? length : bytes.Length;
Array.Copy (bytes, 0, byteBuffer, bufferOffset, copyLength);
}
column.lobOffset += bytes.Length;
bufferOffset += bytes.Length;
length -= bytes.Length;
}
}
}
return column.lobOffset - startOffset;
}