RunInCoreAsync() public method

public RunInCoreAsync ( System.Action code ) : void
code System.Action
return void
Esempio n. 1
0
        void WebQuery(object parameter)
        {
            WebCache cache = parameter as WebCache;

            if (ThinkOnline)
            {
                cache.LastTried = Core.TimeNow;
            }

            cache.NextQuery = Retry.NextTry;

            Network.UpdateLog("general", "Trying webcache");

            string response = MakeWebCacheRequest(cache, "query:" + Network.OpID.ToString());

            // check for empty or error
            if (response.StartsWith("error:"))
            {
                Network.UpdateLog("WebCache", "Query: " + cache.Address + ": " + response);
                return;
            }
            else
            {
                Network.UpdateLog("general", "Webcache success");
            }

            // else success
            cache.LastSeen = Core.TimeNow;

            NextWebQuery = Core.TimeNow.AddSeconds(10);  // cache.nextry will keep any individual cache from being tried too often

            // if cache is low this will be restarted
            Core.RunInCoreAsync(delegate() { WebQueryResponse(cache, response); });
        }
Esempio n. 2
0
        void OpBootstrap()
        {
            OpCore lookup = Core.Context.Lookup;

            // find operation nodes through global net at expanding intervals
            // called from operation network's bootstrap
            if (lookup != null &&
                Core.User.Settings.OpAccess != AccessType.Secret &&
                lookup.Network.Responsive)
            {
                LookupearchInterval.Timer();

                if (Core.TimeNow > NextLookupSearch)
                {
                    NextLookupSearch = LookupearchInterval.NextTry;

                    Network.UpdateLog("general", "Looking for " + Core.User.Settings.Operation);

                    lookup.RunInCoreAsync(delegate()
                    {
                        LookupService service = lookup.GetService(ServiceIDs.Lookup) as LookupService;
                        service.LookupCache.Search(Network.OpID, null, Search_FoundLookup);
                    });
                }
            }

            TryWebCache();

            TryIPCache();
        }