Ignore:
Timestamp:
Feb 11, 2010, 8:54:10 PM (12 years ago)
Author:
arnold
Message:

1) Killed the LayoutUpdated-Event in WPF because it consumed 60-90% of the cpu load...
2) Changes Threading.Timer to Timers.Timer in P2PSubscriberBase.

Location:
trunk/CrypPlugins/PeerToPeerManager_NEW
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerPresentation.xaml.cs

    r1137 r1139  
    2727        {
    2828            InitializeComponent();
    29             SizeChanged += new SizeChangedEventHandler(P2PManagerPresentation_SizeChanged);
     29            this.SizeChanged += new SizeChangedEventHandler(P2PManagerPresentation_SizeChanged);
    3030            this.DataContext = entries;
    31             this.LayoutUpdated += new EventHandler(P2PManagerPresentation_LayoutUpdated);
     31            // when you uncomment this line, you burn 70% of the whole CPU time for Resizing this view...
     32            //this.LayoutUpdated += new EventHandler(P2PManagerPresentation_LayoutUpdated);
     33            this.Expander_JobStatus.Expanded += new RoutedEventHandler(Expander_JobStatus_Expanded);
     34            this.Expander_List.Expanded += new RoutedEventHandler(Expander_List_Expanded);
     35            this.Expander_WorkerInfo.Expanded += new RoutedEventHandler(Expander_WorkerInfo_Expanded);
     36            //this.ListView.DataContextChanged += new DependencyPropertyChangedEventHandler(ListView_DataContextChanged);
     37            //this.ListView.SizeChanged += new SizeChangedEventHandler(ListView_SizeChanged);
     38            this.ListView.SourceUpdated += new EventHandler<DataTransferEventArgs>(ListView_SourceUpdated);
     39        }
     40
     41        void Grid_LayoutUpdated(object sender, EventArgs e)
     42        {
     43            FunnyResize();
     44        }
     45
     46        void Canvas_LayoutUpdated(object sender, EventArgs e)
     47        {
     48            FunnyResize();
     49        }
     50
     51        void ListView_SourceUpdated(object sender, DataTransferEventArgs e)
     52        {
     53            FunnyResize();
     54        }
     55
     56        void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
     57        {
     58            FunnyResize();
     59        }
     60
     61        void ListView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
     62        {
     63            FunnyResize();
     64        }
     65
     66        void Expander_WorkerInfo_Expanded(object sender, RoutedEventArgs e)
     67        {
     68            FunnyResize();
     69        }
     70
     71        void Expander_List_Expanded(object sender, RoutedEventArgs e)
     72        {
     73            FunnyResize();
     74        }
     75
     76        void Expander_JobStatus_Expanded(object sender, RoutedEventArgs e)
     77        {
     78            FunnyResize();
    3279        }
    3380
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManager_KeyPattern.cs

    r1137 r1139  
    277277            }
    278278
    279             if (e.PropertyName == "TopicName")
    280             {
    281                 GuiLogMessage("Topic Name has changed, so all subscribers must reconfirm registering!", NotificationLevel.Warning);
    282                 // stop active publisher and tell all subscribers that topic name isn't valid anymore
    283                 Stop();
    284                 //this.p2pManager.Stop(PubSubMessageType.Unregister);
    285                 // start publisher for the changed topic
    286                 process(this.EncryptionControl);
    287                 //this.p2pManager.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
    288             }
     279            if (this.p2pControl == null)
     280                return;
    289281            if (e.PropertyName == "BtnUnregister")
    290282            {
    291                 Stop();
    292                 //this.p2pManager.Stop(PubSubMessageType.Unregister);
    293                 GuiLogMessage("Unregister button pressed, Publisher has stopped!", NotificationLevel.Info);
     283                if (this.p2pManager != null && this.p2pManager.Started)
     284                {
     285                    Stop();
     286                    //this.p2pManager.Stop(PubSubMessageType.Unregister);
     287                    GuiLogMessage("Unregister button pressed, Publisher has stopped!", NotificationLevel.Info);
     288                }
    294289            }
    295290            if (e.PropertyName == "BtnRegister")
    296291            {
    297                 this.process(this.EncryptionControl);
    298                 GuiLogMessage("Register button pressed, Publisher has been started!", NotificationLevel.Info);
     292                if (this.p2pManager == null || !this.p2pManager.Started)
     293                {
     294                    this.process(this.EncryptionControl);
     295                    GuiLogMessage("Register button pressed, Publisher has been started!", NotificationLevel.Info);
     296                }
    299297            }
    300298            if (e.PropertyName == "BtnSolutionFound")
    301299            {
    302                 Stop();
    303                 //this.p2pManager.Stop(PubSubMessageType.Solution);
    304                 GuiLogMessage("TEST: Emulate Solution-Found-message", NotificationLevel.Info);
     300                if (this.p2pManager != null && this.p2pManager.Started)
     301                {
     302                    Stop();
     303                    //this.p2pManager.Stop(PubSubMessageType.Solution);
     304                    GuiLogMessage("TEST: Emulate Solution-Found-message", NotificationLevel.Info);
     305                }
    305306            }
    306307        }
     
    333334                this.p2pManager.Stop(PubSubMessageType.Unregister);
    334335                this.settings.MngStatusChanged(P2PManager_KeyPatternSettings.MngStatus.Neutral);
     336                this.p2pManager.OnGuiMessage -= p2pManager_OnGuiMessage;
     337                this.p2pManager.OnProcessProgress -= p2pManager_OnProcessProgress;
     338                this.p2pManager.OnNewJobAllocated -= p2pManager_OnNewJobAllocated;
     339                this.p2pManager.OnNoMoreJobsLeft -= p2pManager_OnNoMoreJobsLeft;
     340                this.p2pManager.OnResultReceived -= p2pManager_OnResultReceived;
     341                // set Manager to null, so after restarting the Workspace,
     342                // a new Distributable stop will be initialized with (maybe)
     343                // changed settings
     344                this.p2pManager = null;
    335345            }
    336346        }
     
    392402                byte[] byteEncryptedData = null;
    393403                CryptoolStream newEncryptedData = new CryptoolStream();
    394                 newEncryptedData.OpenRead(this.DecryptedData.FileName);
    395                 if (newEncryptedData.CanRead)
    396                 {
     404                try
     405                {
     406                    newEncryptedData.OpenRead(this.DecryptedData.FileName);
    397407                    // Convert CryptoolStream to an byte Array and store it in the DHT
    398408                    if (newEncryptedData.Length > Int32.MaxValue)
     
    403413                        throw (new Exception("Read Data are shorter than byteArrayLen"));
    404414                }
    405                 else
    406                     throw (new Exception("Fatal error while reading the CryptoolStream."));
    407 
     415                catch (Exception ex)
     416                {
     417                    throw (new Exception("Fatal error while reading the CryptoolStream. Exception: " + ex.ToString()));
     418                }
     419                finally
     420                {
     421                    newEncryptedData.Close();
     422                    newEncryptedData.Dispose();
     423                }
     424                             
    408425                string pattern = this.encryptionControl.getKeyPattern();
    409426                KeyPattern kp = new KeyPattern(pattern);
     
    417434                    return;
    418435                }
    419 
    420436
    421437                // create a new DistributableJob instance
     
    434450
    435451            this.settings.MngStatusChanged(P2PManager_KeyPatternSettings.MngStatus.Working);
    436             /*End Testspace*/
    437452        }
    438453
Note: See TracChangeset for help on using the changeset viewer.