 |
| 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
|
|
|
|

June 29th, 2006, 10:11 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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;
}
|
|

July 2nd, 2006, 08:19 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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="";
}
}
|
|

July 2nd, 2006, 01:33 PM
|
|
Friend of Wrox
|
|
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

July 2nd, 2006, 08:41 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi thnks for replying ~! but how i gonna use thread?
|
|

July 2nd, 2006, 09:06 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
nvm.. i try to read more abt thread first~~ thnkS for replying mi =)
|
|

July 4th, 2006, 03:13 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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="";
}
}
|
|
 |