本文整理汇总了C#中Promise.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# Promise.Cancel方法的具体用法?C# Promise.Cancel怎么用?C# Promise.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Promise
的用法示例。
在下文中一共展示了Promise.Cancel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlMetadata
private SqlMetadata(SqlConnection conn)
{
_conn = conn;
_objectPromise = new Promise<IEnumerable<SqlObject>>();
new SqlCommand(@"SELECT SCHEMA_NAME(SCHEMA_ID) sch
, name
, case when type in ('D') then 'Constraint'
when type in ('F', 'PK', 'UQ') then 'Key'
when type in ('S', 'IT', 'U') then 'Table'
when type in ('IF', 'FN', 'TF') then 'Function'
when type in ('P') then 'Procedure'
when type in ('V') then 'View'
else type end type
, case when type in ('IF', 'TF') then 1
when type = 'PK' then 2 else 0 end sub_type
, object_id
, parent_object_id
FROM sys.objects AS SO
UNION ALL
SELECT
SCHEMA_NAME(o.schema_id) + '.[' + o.name + ']' sch
, ind.name
, 'Index'
, 0 table_valued
, ind.index_id object_id
, ind.object_id parent_object_id
FROM sys.indexes ind
inner join sys.[objects] o
on o.object_id = ind.object_id
WHERE
ind.is_primary_key = 0
AND ind.is_unique = 0
AND ind.is_unique_constraint = 0
AND o.is_ms_shipped = 0", conn)
.GetListAsync<SqlObject>(async (r) => SqlObject.Create(
await r.GetFieldStringAsync(0),
await r.GetFieldStringAsync(1),
await r.GetFieldStringAsync(2),
await r.GetFieldIntAsync(4),
await r.GetFieldIntAsync(5),
(SqlSubType)await r.GetFieldIntAsync(3)
)).ContinueWith(l =>
{
if (l.IsFaulted)
{
_objectPromise.Reject(l.Exception);
}
else if (l.IsCanceled)
{
_objectPromise.Cancel();
}
else
{
var items = l.Result.Concat(_systemViews);
_objects = items.ToDictionary(o => o.Schema + "." + o.Name, StringComparer.OrdinalIgnoreCase);
_schemas = items.Where(o => !string.IsNullOrEmpty(o.Schema)).Select(o => o.Schema).Distinct().ToArray();
_objectPromise.Resolve(_objects.Values);
}
});
}