예제 #1
0
 public void Config(MessageGlobalConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     OnConfig?.Invoke(config);
 }
예제 #2
0
        private void Config(int num, CancellationToken ct)
        {
            while (_wordlist.HasNext && !_theEnd)
            {
                int    retry = 0;
                string data  = _wordlist.GetData();

Retry:

                if (ct.IsCancellationRequested)
                {
                    break;
                }

                try
                {
                    Proxy proxy = null;
                    if (!_proxylist.Less)
                    {
                        proxy = _proxylist.Get();
                        if (proxy == null)
                        {
                            goto Retry;
                        }
                    }

                    Status?status = Status.OK;
                    status = OnConfig?.Invoke(this, new DataEventArgs()
                    {
                        Retry = retry,
                        Data  = data,
                        Proxy = proxy,
                        Save  = _save,
                        Log   = _log
                    });

                    switch (status)
                    {
                    case Status.OK:
                        _datapool.Add();
                        break;

                    case Status.Retry:
                        retry++;
                        goto Retry;

                    case Status.TheEnd:
                        _theEnd = true;
                        break;

                    default:
                        _datapool.Add();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    OnException?.Invoke(this, new ExceptionEventArgs()
                    {
                        Location  = "OnConfig",
                        Exception = ex,
                        Log       = _log
                    });
                }
            }

            _threadList[num] = null;
        }