本文整理汇总了C#中Common.makeStreamReaderFromResult方法的典型用法代码示例。如果您正苦于以下问题:C# Common.makeStreamReaderFromResult方法的具体用法?C# Common.makeStreamReaderFromResult怎么用?C# Common.makeStreamReaderFromResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common.makeStreamReaderFromResult方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleNewsResult
private void HandleNewsResult(IAsyncResult result)
{
try
{
var common = new Common();
var binding = (result.AsyncState as AsyncState).binding as News;
News rv; //Our return value.
/*
* StreamReaders implement the IDisposable interface, so the best practice is to
* wrap them in using statements so the object's is disposed once the scope passes.
*
* Only classes with expensive resources (data connections, large buffers, network handles, etc...) implement
* IDisposable - in this case StreamReader just uses a buffer and it's probably not that large in this case,
* but it's still a good practice. -Aaron
*/
using (var txt = common.makeStreamReaderFromResult(result))
{
rv = common.deserializeStreamReader<News>(txt);
}
this.Dispatcher.BeginInvoke(
() =>
{
binding.nextId = rv.nextId;
binding.version = rv.version;
binding.items = rv.items;
// FIXME: Shouldn't I be able to do this instead?
//binding = processJsonString(txt);
SetProgressBar(false);
}
);
}
catch (WebException e)
{
this.Dispatcher.BeginInvoke(
() =>
{
//errorLine.Text = e.Message;
//errorLine.Visibility = Visibility.Visible;
SetProgressBar(false);
}
);
}
}
示例2: HandleCommentResult
private void HandleCommentResult(IAsyncResult result)
{
try
{
Common common = new Common();
var binding = (result.AsyncState as AsyncState).binding as FlatComments;
StreamReader txt = common.makeStreamReaderFromResult(result);
Comments comments = common.deserializeStreamReader<Comments>(txt);
this.Dispatcher.BeginInvoke(
() =>
{
textTextBlock.Text = stripHtml(comments.text);
binding.comments = flattenComments(comments.comments);
setProgressBar(false);
}
);
}
catch (WebException e)
{
this.Dispatcher.BeginInvoke(
() =>
{
setProgressBar(false);
}
);
}
}
示例3: HandleNewsResult
private void HandleNewsResult(IAsyncResult result)
{
try
{
Common common = new Common();
var binding = (result.AsyncState as AsyncState).binding as News;
StreamReader txt = common.makeStreamReaderFromResult(result);
News rv = common.deserializeStreamReader<News>(txt);
this.Dispatcher.BeginInvoke(
() =>
{
binding.nextId = rv.nextId;
binding.version = rv.version;
binding.items = rv.items;
// FIXME: Shouldn't I be able to do this instead?
//binding = processJsonString(txt);
setProgressBar(false);
}
);
}
catch (WebException e)
{
this.Dispatcher.BeginInvoke(
() =>
{
//errorLine.Text = e.Message;
//errorLine.Visibility = Visibility.Visible;
setProgressBar(false);
}
);
}
}