本文整理汇总了C#中AsyncCallback.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# AsyncCallback.Invoke方法的具体用法?C# AsyncCallback.Invoke怎么用?C# AsyncCallback.Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsyncCallback
的用法示例。
在下文中一共展示了AsyncCallback.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeCallback
private static void InvokeCallback(AsyncCallback callback, IAsyncResult result)
{
if (callback != null)
{
callback.Invoke(result);
}
}
开发者ID:ConnorMcMahon,项目名称:azure-webjobs-sdk,代码行数:7,代码来源:ReturnsThrowsOfCloudBlobStreamICancellableAsyncResultExtensions.cs
示例2: BeginDownloadXml
public override IAsyncResult BeginDownloadXml(Uri feeduri, AsyncCallback callback)
{
#if !WINDOWS_PHONE
if (!IsolatedStorageFile.IsEnabled) throw new MissingFeedException("IsolatedStorage is not enabled! Cannot access files from IsolatedStorage!");
#endif
try
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if(!PingFeed(feeduri, store)) throw new MissingFeedException(string.Format("Could not find feed at location {0}", feeduri));
using (var stream = new IsolatedStorageFileStream(feeduri.OriginalString, FileMode.Open,
FileAccess.Read, store))
{
using(var reader = new StreamReader(stream))
{
var strOutput = reader.ReadToEnd();
//Fake the async result
var result = new AsyncResult<FeedTuple>(callback, new FeedTuple { FeedContent = strOutput, FeedUri = feeduri }, true);
if (callback != null) callback.Invoke(result);
return result;
}
}
}
}
catch (IsolatedStorageException ex)
{
throw new MissingFeedException(string.Format("Unable to open feed at {0}", feeduri), ex);
}
}
示例3: BeginRead
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
var task = ReadAsync(buffer, offset, count, CancellationToken.None, state);
if (callback != null)
{
task.ContinueWith(t => callback.Invoke(t));
}
return task;
}
示例4: BeginCommit
public override ICancellableAsyncResult BeginCommit(AsyncCallback callback, object state)
{
Commit();
ICancellableAsyncResult result = new CompletedCancellableAsyncResult(state);
if (callback != null)
{
callback.Invoke(result);
}
return result;
}
示例5: ReadContextBegin
public void ReadContextBegin(Stream oStream, AsyncCallback fCallback, object oParam)
{
try
{
m_oStream = oStream;
m_oParam = oParam;
int nInputLength = (int)m_oStream.Length;
m_aBuffer = new byte[nInputLength];
m_oStream.BeginRead(m_aBuffer, 0, nInputLength, fCallback, oParam);
}
catch
{
m_eError = ErrorTypes.ReadRequestStream;
}
if (ErrorTypes.NoError != m_eError)
fCallback.Invoke(new AsyncOperationData(oParam));
}
示例6: updateRequierdData
public async void updateRequierdData(int days, AsyncCallback callback, AsyncCallback failCallback)
{
DateTime today= DateTime.Now;
LocalWeatherInput weatherInput = new LocalWeatherInput();
weatherInput.num_of_days = days.ToString();
callback.Invoke(new Task((object obj) => { },
string.Format(" {0} place will be updated!", places.Count)));
try
{
foreach (string langName in VoiceCommandInfo.AvailableLanguages)
{
if (VoiceCommandService.InstalledCommandSets.ContainsKey(langName))
{
VoiceCommandSet widgetVcs = VoiceCommandService.InstalledCommandSets[langName];
widgetVcs.UpdatePhraseListAsync("place", places.Keys);
}
}
}
catch (Exception e)
{
BugReporter.GetInstance().report(e);
}
foreach (KeyValuePair<string, Place> dictionaryEntry in places)
{
Place place = dictionaryEntry.Value;
if (place.LastUpdateTime > DateTime.Now.AddHours(-2) && !Settings.GetInstance().APIKey.Any())
{
callback.Invoke(new Task((object obj) => { },
"current weather data for " + place.Name + " is not outdated yet!"));
continue;
}
if (place._useName)
weatherInput.query = place.Name;
else
weatherInput.query = place.Latitude + "," + place.Longitude;
SaveWeatherDataClass saver = new SaveWeatherDataClass(place.Name,callback);
new FreeAPI().GetLocalWeather(weatherInput,saver.SaveWeatherData, failCallback);
Thread.Sleep(1000);
}
}
示例7: ReadContextBegin
public void ReadContextBegin(Stream oStream, AsyncCallback fCallback, object oParam)
{
ErrorTypes eError = ErrorTypes.NoError;
try
{
m_oStream = oStream;
m_fAsyncCallback = fCallback;
m_oParam = oParam;
m_oStream.BeginRead(m_aBuffer, 0, m_aBuffer.Length, ClearCacheTaskResultCallback, null);
}
catch
{
eError = ErrorTypes.ReadRequestStream;
}
if (ErrorTypes.NoError != eError)
{
m_eError = eError;
fCallback.Invoke(new AsyncOperationData(oParam));
}
}
示例8: BeginReceiveFrom
public IAsyncResult BeginReceiveFrom(byte[] buffer, ref EndPoint remoteEndPoint, AsyncCallback asynCallback, object state)
{
var ar = new MockedAsyncResult(state);
Encoding.ASCII.GetBytes(MessageString).CopyTo(buffer, 0);
asynCallback.Invoke(ar);
return ar;
}
示例9: BeginInvokeCore
protected override IAsyncResult BeginInvokeCore(InvokeArgs invokeArgs, AsyncCallback callback, object userState)
{
MockAsyncResult ar = new MockAsyncResult(null, userState, new object[] { invokeArgs.OperationName, invokeArgs.ReturnType, invokeArgs.Parameters, userState });
// do the invoke and get the return value
if (invokeArgs.OperationName == "Echo")
{
ar.ReturnValue = "Echo: " + (string)invokeArgs.Parameters.Values.First();
}
callback.Invoke(ar);
return ar;
}
示例10: BeginSubmitCore
protected override IAsyncResult BeginSubmitCore(EntityChangeSet changeSet, AsyncCallback callback, object userState)
{
IEnumerable<ChangeSetEntry> submitOperations = changeSet.GetChangeSetEntries();
MockAsyncResult ar = new MockAsyncResult(null, userState, new object[] { changeSet, submitOperations, userState });
// perform mock submit operations
callback.Invoke(ar);
return ar;
}
示例11: BeginQueryCore
protected override IAsyncResult BeginQueryCore(EntityQuery query, AsyncCallback callback, object userState)
{
// load test data and get query result
IEnumerable<Entity> entities = GetQueryResult(query.QueryName, query.Parameters);
if (query.Query != null)
{
entities = RebaseQuery(entities.AsQueryable(), query.Query).Cast<Entity>();
}
MockAsyncResult ar = new MockAsyncResult(entities, userState, null);
callback.Invoke(ar);
return ar;
}
示例12: GetBookmarks
public void GetBookmarks(Folder folder, AsyncCallback callback)
{
String url = "https://www.instapaper.com/api/1/bookmarks/list";
String[] scriptParams = { url, "folder_id", folder.Id };
callApi(url, scriptParams, new AsyncCallback(delegate(IAsyncResult res)
{
String respResult = readResult();
List<Bookmark> bookmarks = new List<Bookmark>();
JsonParser parser = new JsonParser(respResult);
var parsedBookmarksResult = parser.Decode();
ArrayList bookmarkArray = parsedBookmarksResult as ArrayList;
foreach (Dictionary<String, Object> bookmark in bookmarkArray)
{
if ((bookmark["type"] as String).Equals("bookmark"))
{
Bookmark current = new Bookmark(this);
current.Id = (String)bookmark["bookmark_id"];
current.Title = (String)bookmark["title"];
current.Url = (String)bookmark["url"];
current.Starred = ((String)bookmark["starred"]).Equals("1");
bookmarks.Add(current);
}
}
folder.Bookmarks = bookmarks;
callback.Invoke(res);
}));
}
示例13: UnStarBookmark
public void UnStarBookmark(Bookmark bookmark, AsyncCallback callback)
{
String url = "https://www.instapaper.com/api/1/bookmarks/unstar";
String[] scriptParams = { url, "bookmark_id", bookmark.Id };
callApi(url, scriptParams, new AsyncCallback(delegate(IAsyncResult res)
{
bookmark.Starred = false;
callback.Invoke(res);
}));
}
示例14: GetFolderList
public void GetFolderList(User user, AsyncCallback callback)
{
String url = "https://www.instapaper.com/api/1/folders/list";
String[] scriptParams = { url };
callApi(url, scriptParams, delegate(IAsyncResult result){
String respResult = readResult();
List<Folder> folders = new List<Folder>();
// manually add the predefined folders
Folder unread = new Folder(this);
unread.Id = Folder.UNREAD;
unread.Title = "Unread";
Folder starred = new Folder(this);
starred.Id = Folder.STARRED;
starred.Title = "Starred";
Folder archive = new Folder(this);
archive.Id = Folder.ARCHIVE;
archive.Title = "Archive";
folders.Add(unread);
folders.Add(starred);
folders.Add(archive);
JsonParser parser = new JsonParser(respResult);
var parsedFolderResult = parser.Decode();
ArrayList folderArray = parsedFolderResult as ArrayList;
foreach (Dictionary<String, Object> folder in folderArray)
{
Folder current = new Folder(this);
current.Id = folder["folder_id"] as String;
current.Title = folder["title"] as String;
folders.Add(current);
}
user.Folders = folders;
callback.Invoke(result);
});
}
示例15: GetBookmarkText
public void GetBookmarkText(Bookmark bookmark, AsyncCallback callback)
{
String url = "https://www.instapaper.com/api/1/bookmarks/get_text";
String[] scriptParams = { url, "bookmark_id", bookmark.Id };
callApi(url, scriptParams, new AsyncCallback(delegate(IAsyncResult res) {
bookmark.HtmlText = readResult();
callback.Invoke(res);
}));
}