Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2006, 10:11 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default can someone help mi >?

Hi there,
when i click Yes. A command prompt will come out and the progress bar will start. But two of them cannot work at one time ..once the command prompt appeared the progress bar will stuck... can someone help mi?

My dialog box. Once it click
'Yes', it will start to do the process...

if (key == DialogResult.Yes)
            {

                string conv = EsTime(t);
                int conv1 = Convert.ToInt32(conv.Substring(0,2));
                timer1.Enabled = true;


                                progressBar1.Value = 0 ;
                //60000ms
                progressBar1.Maximum = conv1*60000;
                progressBar1.Step = 1;


                Process process = new Process();
                process.StartInfo = new ProcessStartInfo( @"C:\Documents and Settings\Administrator\Desktop\Final Work\mencoder.exe",text1);
                //process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
                process.Start();
                //start my progressBar1
                for(int i=progressBar1.Minimum; i <= progressBar1.Maximum; i++)
                {
                    progressBar1.PerformStep();

                }






My timer:

        private void timer1_Tick(object sender, System.EventArgs e)
        {

            progressBar1.PerformStep();
            if(progressBar1.Maximum == progressBar1.Value)
            {
                timer1.Enabled = false;

            }

 
Old July 2nd, 2006, 08:19 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is my latest improvement.. i still have the same problem... can someone help mi ?


private void buttonConvert_Click(object sender, System.EventArgs e)
        {
            text1="\""+labelTargetOpenValue.Text.ToString()+"\ " -o \""+labelTargetPathValue.Text.ToString()+"\" -vf kerndeint -oac mp3lame -ovc xvid -xvidencopts pass=1:bitrate=4000:vhq=1:max_bframes=0";
            text2=labelTargetOpenValue.Text.ToString();
            text3=labelTargetOpenValue.Text.ToString();
            text4=labelTargetOpenValue.Text.ToString();

            FileInfo f = new FileInfo(text2);
            FileInfo a = new FileInfo(text3);
            FileInfo t = new FileInfo(text4);



            MessageBox.Show("Size of the file to convert is: " +ShowSize(f)+ "\n\nEstimated file size after conversion: "+AddSize(a)+ "\n\nEstimated time is less than: "+EsTime(t), "Information");

            DialogResult key = MessageBox.Show(
                "This utilise 100% CPU process \n\n Are You sure that you want to convert?",
                "Confirm",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question);

        // here is where i click "yes" the progress bar will start and the command prompt will come out. But once the command prompt come out the progress bar will stuck... do i need to use thread or anything? some experts out there i need help thx..

            if (key == DialogResult.Yes)
            { [yellow]
                //convert to int

                string conv = EsTime(t);
                int conv1 = Convert.ToInt32(conv.Substring(0,2));
                timer1.Enabled = true;
                progressBar1.Value = 0 ;
                //60000ms
                progressBar1.Maximum = conv1*60000;
                progressBar1.Step = 1;

                //this.timer1.Enabled = true;
                //this.progressBar1.Text = "COUNTING";
                Process process = new Process();
                process.StartInfo = new ProcessStartInfo( @"C:\Documents and Settings\Administrator\Desktop\Final Work\mencoder.exe",text1);
                //process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
                process.Start();

                for(int i=progressBar1.Minimum; i <= progressBar1.Maximum; i++)
                {
                    progressBar1.PerformStep();

                }
            }
            else if (key == DialogResult.No)
            {
                labelTargetOpenValue.Text="";
                labelTargetPathValue.Text="";
            }
        }


 
Old July 2nd, 2006, 01:33 PM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use threads to continue progress in the Progressbar and at the same time start the process.

It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old July 2nd, 2006, 08:41 PM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi thnks for replying ~! but how i gonna use thread?

 
Old July 2nd, 2006, 09:06 PM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

nvm.. i try to read more abt thread first~~ thnkS for replying mi =)

 
Old July 4th, 2006, 03:13 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can someone help mi i still have the same mistake...

        public void startthread()
        {
            // Make FormMediaConverter class.
            FormMediaConverter j = new FormMediaConverter();
            // Now make and start the background thread.
            Thread backgroundThread = new Thread(new ThreadStart(j.hello));
            backgroundThread.Start();

        }




private void buttonConvert_Click(object sender, System.EventArgs e)
        {
            text1="\""+labelTargetOpenValue.Text.ToString()+"\ " -o \""+labelTargetPathValue.Text.ToString()+"\" -vf kerndeint -oac mp3lame -ovc xvid -xvidencopts pass=1:bitrate=4000:vhq=1:max_bframes=0";
            text2=labelTargetOpenValue.Text.ToString();
            text3=labelTargetOpenValue.Text.ToString();
            text4=labelTargetOpenValue.Text.ToString();

            FileInfo f = new FileInfo(text2);
            FileInfo a = new FileInfo(text3);
            FileInfo t = new FileInfo(text4);



            MessageBox.Show("Size of the file to convert is: " +ShowSize(f)+ "\n\nEstimated file size after conversion: "+AddSize(a)+ "\n\nEstimated time is less than: "+EsTime(t), "Information");

            DialogResult key = MessageBox.Show(
                "This utilise 100% CPU process \n\n Are You sure that you want to convert?",
                "Confirm",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question);

        // here is where i click "yes" the progress bar will start and the command prompt will come out. But once the command prompt come out the progress bar will stuck... do i need to use thread or anything? some experts out there i need help thx..

            if (key == DialogResult.Yes)
            { [yellow]
                //convert to int

                string conv = EsTime(t);
                int conv1 = Convert.ToInt32(conv.Substring(0,2));
                timer1.Enabled = true;
                progressBar1.Value = 0 ;
                //60000ms
                progressBar1.Maximum = conv1*60000;
                progressBar1.Step = 1;

                //this.timer1.Enabled = true;
                //this.progressBar1.Text = "COUNTING";
                Process process = new Process();
                process.StartInfo = new ProcessStartInfo( @"C:\Documents and Settings\Administrator\Desktop\Final Work\mencoder.exe",text1);
                //process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
                process.Start();


                //This is where i start my thread but still have the same problem.........SOMEONE PLS HELP MI ..
                startthread();




                for(int i=progressBar1.Minimum; i <= progressBar1.Maximum; i++)
                {
                    progressBar1.PerformStep();

                }
            }
            else if (key == DialogResult.No)
            {
                labelTargetOpenValue.Text="";
                labelTargetPathValue.Text="";
            }
        }











Similar Threads
Thread Thread Starter Forum Replies Last Post
can someone help mi ? g0dchild_85 C# 5 August 9th, 2006 09:31 AM
can someone help mi ? i m quite a newbie ..[xx(] g0dchild_85 ASP.NET 1.0 and 1.1 Basics 4 June 9th, 2006 12:59 PM
Chpt 7 >> Pg 245 >>Try It Out #4-5 harrison4411 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 March 2nd, 2006 06:26 PM
Achitecture ? SQL -> XML -> ASP -> PDF or HTML Frm jstrong Classic ASP XML 0 July 9th, 2005 01:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.