Click here to Skip to main content
15,895,256 members
Home / Discussions / C#
   

C#

 
AnswerRe: Memory leak Pin
Russell Jones4-Apr-07 6:06
Russell Jones4-Apr-07 6:06 
GeneralRe: Memory leak Pin
HexaDeveloper4-Apr-07 7:44
HexaDeveloper4-Apr-07 7:44 
GeneralRe: Memory leak Pin
Luc Pattyn4-Apr-07 11:06
sitebuilderLuc Pattyn4-Apr-07 11:06 
GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 5:49
HexaDeveloper8-Apr-07 5:49 
GeneralRe: Memory leak Pin
Luc Pattyn8-Apr-07 6:37
sitebuilderLuc Pattyn8-Apr-07 6:37 
GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 6:49
HexaDeveloper8-Apr-07 6:49 
GeneralRe: Memory leak Pin
Luc Pattyn8-Apr-07 7:08
sitebuilderLuc Pattyn8-Apr-07 7:08 
GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 7:12
HexaDeveloper8-Apr-07 7:12 
private void btn_simulate_Click(object sender, EventArgs e)<br />
        {<br />
            this.btn_simulate.Enabled = false;<br />
            this.btn_stop.Enabled = true;<br />
            closeThreadRequested = false;<br />
            if (!packetsMovingThread.IsBusy)<br />
                packetsMovingThread.RunWorkerAsync();<br />
            <br />
        }<br />
        /// <summary><br />
        /// When press the button stop simulation <br />
        /// </summary><br />
        private void btn_stop_Click(object sender, EventArgs e)<br />
        {<br />
            closeThreadRequested = true;<br />
            this.btn_stop.Enabled = false;<br />
            this.btn_simulate.Enabled = true;<br />
            if (packetsMovingThread.IsBusy)<br />
                packetsMovingThread.CancelAsync();<br />
        }<br />
        /// <summary><br />
        /// An event handler that called when thread of background task begin   <br />
        /// </summary><br />
        private void packetsMovingThread_DoWork(object sender, DoWorkEventArgs e)<br />
        {<br />
            BackgroundWorker worker = sender as BackgroundWorker;<br />
            if (worker.CancellationPending)<br />
                e.Cancel = true;<br />
            else<br />
                dataPacket.simulate(lineArray, closeThreadRequested, ref source_pnt,<br />
                    ref destination_pnt, packetsMovingThread);<br />
        }<br />
        /// <summary><br />
        /// An event handler that called when thread of background task Aborted<br />
        /// for any reason(Error,Cancel,Normal Completion)  <br />
        /// </summary><br />
        private void packetsMovingThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)<br />
        {<br />
            if (e.Error != null)<br />
                MessageBox.Show(e.Error.Message);<br />
            else if (e.Cancelled)<br />
                MessageBox.Show("Cancelled");<br />
        }<br />
        /// <summary><br />
        /// An event handler that called when thread of background task has changes in <br />
        /// its state or by calling ReportChanges() method<br />
        /// </summary><br />
        private void packetsMovingThread_ProgressChanged(object sender, ProgressChangedEventArgs e)<br />
        {<br />
            if (closeThreadRequested == false && !(source_pnt.IsEmpty))<br />
            {<br />
                dataPacket.drawPacket(this.CreateGraphics(), source_pnt);<br />
            }<br />
            Invalidate(drawingFrame);<br />
            // update here make bad effect on memory<br />
            //Update(); <br />
        }

public void drawPacket(Graphics grfx, Point location)<br />
     {<br />
         Pen pen = new Pen(type);<br />
         SolidBrush solidBrush = new SolidBrush(type);<br />
         grfx.DrawRectangle(pen, location.X, location.Y, 4, 4);<br />
         grfx.FillRectangle(solidBrush, location.X, location.Y, 4, 4);<br />
         pen.Dispose();<br />
         solidBrush.Dispose();<br />
     }

movePacket method compute next point and call
packetMovingThread(declared object).ReportProgress(100);

Generator
GeneralRe: Memory leak [modified] Pin
Luc Pattyn8-Apr-07 11:21
sitebuilderLuc Pattyn8-Apr-07 11:21 
GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 12:43
HexaDeveloper8-Apr-07 12:43 
GeneralRe: Memory leak Pin
Luc Pattyn8-Apr-07 13:05
sitebuilderLuc Pattyn8-Apr-07 13:05 
QuestionGet Controls by name Pin
swjam4-Apr-07 5:03
swjam4-Apr-07 5:03 
AnswerRe: Get Controls by name Pin
B.King4-Apr-07 5:50
B.King4-Apr-07 5:50 
QuestionHow to specify an event handler Pin
peterchen4-Apr-07 5:02
peterchen4-Apr-07 5:02 
AnswerRe: How to specify an event handler Pin
mikanu4-Apr-07 6:48
mikanu4-Apr-07 6:48 
QuestionMulti-select ComboBox Pin
Amatista4-Apr-07 4:46
Amatista4-Apr-07 4:46 
AnswerRe: Multi-select ComboBox Pin
Douglas Troy4-Apr-07 6:00
Douglas Troy4-Apr-07 6:00 
GeneralRe: Multi-select ComboBox Pin
Amatista4-Apr-07 22:27
Amatista4-Apr-07 22:27 
GeneralRe: Multi-select ComboBox Pin
Douglas Troy5-Apr-07 5:34
Douglas Troy5-Apr-07 5:34 
GeneralRe: Multi-select ComboBox Pin
Amatista10-Apr-07 2:27
Amatista10-Apr-07 2:27 
QuestionControl Draw delay on resize (Getting rid of it) Pin
Muntyness4-Apr-07 3:11
Muntyness4-Apr-07 3:11 
AnswerRe: Control Draw delay on resize (Getting rid of it) Pin
Stanciu Vlad4-Apr-07 7:52
Stanciu Vlad4-Apr-07 7:52 
QuestionMSI uninstall problems Pin
Vadim G.4-Apr-07 2:53
Vadim G.4-Apr-07 2:53 
AnswerRe: MSI uninstall problems Pin
Douglas Troy4-Apr-07 3:51
Douglas Troy4-Apr-07 3:51 
GeneralRe: MSI uninstall problems Pin
Vadim G.4-Apr-07 4:44
Vadim G.4-Apr-07 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.