Changeset 1690


Ignore:
Timestamp:
Jun 22, 2010, 5:38:10 PM (11 years ago)
Author:
Sven Rech
Message:

p2p autostart works now for quadratic sieve

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/QuadraticSieve/QuadraticSieve.cs

    r1678 r1690  
    7272        private static bool alreadyInUse = false;
    7373        private static Mutex alreadyInUseMutex = new Mutex();
     74        private AutoResetEvent waitForConnection = new AutoResetEvent(false);
    7475
    7576        #endregion
     
    155156            if (checkInUse())
    156157                return;
     158
    157159            try
    158160            {
    159161                usePeer2Peer = settings.UsePeer2Peer;
    160                 if (usePeer2Peer && !P2PManager.IsConnected)
     162                if (usePeer2Peer && !P2PManager.IsConnected && P2PManager.IsConnecting)
     163                {
     164                    P2PManager.ConnectionManager.OnP2PConnectionStateChangeOccurred += HandleConnectionStateChange;
     165                    GuiLogMessage("Connecting to Peer2Peer network... Please wait!", NotificationLevel.Info);
     166                    waitForConnection.WaitOne();                   
     167                    P2PManager.ConnectionManager.OnP2PConnectionStateChangeOccurred -= HandleConnectionStateChange;
     168                }
     169                else if (usePeer2Peer && !P2PManager.IsConnected)
    161170                {
    162171                    GuiLogMessage("No connection to Peer2Peer network. Sieving locally now!", NotificationLevel.Warning);
    163172                    usePeer2Peer = false;
    164173                }
     174
    165175                if (usePeer2Peer && settings.Channel.Trim() == "")
    166176                {
     
    278288        }
    279289
     290        private void HandleConnectionStateChange(object sender, bool newState)
     291        {
     292            waitForConnection.Set();
     293        }
     294
    280295        private bool checkInUse()
    281296        {
Note: See TracChangeset for help on using the changeset viewer.