E
Eugene Anthony
I am having a problem with my try and catch found in the code bellow. It
never works when there is no msg in the queue. The code bellow is to
read and process one message at a time. Upon completing the process,
only then will the next and so on msg will be processed.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Messaging;
using System.Threading;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
{
Thread t;
Process pProcess;
int i = 0;
String path;
protected void Page_Load(object sender, EventArgs e)
{
t = new Thread(new ThreadStart(readQueue));
t.Start();
}
public void readQueue()
{
try
{
MessageQueue queue = new
MessageQueue(".\\Private$\\MyPrivateQueue");
Message msg = queue.Receive(new TimeSpan(0, 0, 5));
msg.Formatter = new
System.Messaging.XmlMessageFormatter(new string[] { "System.String" });
Label1.Text = msg.Body.ToString();
path = msg.Body.ToString();
}
catch (MessageQueueException)
{
Label1.Text = "There is no message in the queue";
}
if(Label1.Text.Length == 0)
{
while (!pProcess.HasExited)
{
if(i==0)
{
pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName =
"C:\\Inetpub\\wwwroot\\mencoder.exe";
pProcess.StartInfo.Arguments = "-lavfopts
i_certify_that_my_video_stream_does_not_use_b_frames
C:\\Inetpub\\wwwroot\\MAX.mpg -o C:\\Inetpub\\wwwroot\\vuurwerk1.flv -of
lavf -ovc lavc -oac lavc -lavcopts
vcodec=flv:vbitrate=500:autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:
predia=2:dia=2recmp=2:cmp=2:subcmp=2reme=2:turbo:acodec=mp3:abitrate
=56 -srate 22050 -af lavcresample=22050";
pProcess.Start();
}
i=i+1;
}
}
i = 0;
Thread.Sleep(5000);
t.Start();
}
}
How do I solve the problem?
Your help is kindly appreciated.
Eugene Anthony
never works when there is no msg in the queue. The code bellow is to
read and process one message at a time. Upon completing the process,
only then will the next and so on msg will be processed.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Messaging;
using System.Threading;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
{
Thread t;
Process pProcess;
int i = 0;
String path;
protected void Page_Load(object sender, EventArgs e)
{
t = new Thread(new ThreadStart(readQueue));
t.Start();
}
public void readQueue()
{
try
{
MessageQueue queue = new
MessageQueue(".\\Private$\\MyPrivateQueue");
Message msg = queue.Receive(new TimeSpan(0, 0, 5));
msg.Formatter = new
System.Messaging.XmlMessageFormatter(new string[] { "System.String" });
Label1.Text = msg.Body.ToString();
path = msg.Body.ToString();
}
catch (MessageQueueException)
{
Label1.Text = "There is no message in the queue";
}
if(Label1.Text.Length == 0)
{
while (!pProcess.HasExited)
{
if(i==0)
{
pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName =
"C:\\Inetpub\\wwwroot\\mencoder.exe";
pProcess.StartInfo.Arguments = "-lavfopts
i_certify_that_my_video_stream_does_not_use_b_frames
C:\\Inetpub\\wwwroot\\MAX.mpg -o C:\\Inetpub\\wwwroot\\vuurwerk1.flv -of
lavf -ovc lavc -oac lavc -lavcopts
vcodec=flv:vbitrate=500:autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:
predia=2:dia=2recmp=2:cmp=2:subcmp=2reme=2:turbo:acodec=mp3:abitrate
=56 -srate 22050 -af lavcresample=22050";
pProcess.Start();
}
i=i+1;
}
}
i = 0;
Thread.Sleep(5000);
t.Start();
}
}
How do I solve the problem?
Your help is kindly appreciated.
Eugene Anthony