|
Hi
I am not sure whether i have posted the requirement correctly.
Any how i will try to make it clear.
1. I am having a EXE in the application folder.
2. I have a windows service through which i want to run the exe available in the application folder.
Am i clear now..........
|
|
|
|
|
Yes, it is clear. Same reply applies here. When starting an executable from service it runs on another desktop.
|
|
|
|
|
Ummmm, no.
If he sets up his Process object correctly, he can run an external application.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Try setting the service's Allow service to interact with desktop option to true in the services applet.
Be warned that this is very bad practice.
Cheers,
Vıkram.
"if abusing me makes you a credible then i better give u the chance which didnt get in real" - Adnan Siddiqi.
|
|
|
|
|
|
Thanks, my Georgian friend, I didn't know that.
Can't figure out the lynch votes though.
Cheers,
Vıkram.
"if abusing me makes you a credible then i better give u the chance which didnt get in real" - Adnan Siddiqi.
|
|
|
|
|
You have to provide a lot more info before we have any hope of assisting you.
1) Can you run the application manually?
2) How are you setting up your Process object?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I m coding primative Asynchron calling.
How could i set timeout property to iasyncruslt or my beginxxxasync calls?
|
|
|
|
|
Hi,
I try deverlop source code which can coonect to Camera and get Image from
this camera. In code when I click button capture Image.It have error.
///////////This is My code//////////////////
string sourceURL = "http://192.168.1.4/snapshot.jpg?account=admin& password=12345678&res=0&qual=50";
byte[] buffer = new byte[100000];
int read, total = 0;
// create HTTP request
HttpWebRequest req = (HttpWebRequest) WebRequest.Create( sourceURL );
// get response
WebResponse resp = req.GetResponse( );
// get response stream
Stream stream = resp.GetResponseStream( );
// read data from stream
while ( ( read = stream.Read( buffer, total, 1000 ) ) != 0 )
{
total += read;
}
// get bitmap
Bitmap bmp = (Bitmap) Bitmap.FromStream(
new MemoryStream( buffer, 0, total ) );
////////////////End code
Problem is this line:
Bitmap bmp = (Bitmap) Bitmap.FromStream(
new MemoryStream( buffer, 0, total ) );
it have error message:"Invalid parameter used"
Please help me.
thanks
|
|
|
|
|
erm...why do you need to create a stream from a buffer from a stream?
The original stream wasn't good enough?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Below is the skeleton code which demonstrates the way I have used the BackgroundWorker class. I followed the example provided in MSDN. For some reason MyTimeConsumingTask executes twice before the bgWorker_RunWorkerCompleted handles it.
Any help would be greatly appriciated.
void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
e.Result = MyTimeConsumingTask(e.Argument, worker, e);
}
void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
}
else if ((bool)e.Result)
{
}
else
{
}
}
internal bool MyTimeConsumingTask(object arg, BackgroundWorker worker, DoWorkEventArgs e)
{
Thread.Sleep(10000);
return true;
}
|
|
|
|
|
Put break points and step into the code to see what is wrong.
|
|
|
|
|
Checked with break points at every line of code involving this event.
Although the e.result of first execution is true, the bgWorker_RunWorkerCompleted doesn't handle it but handles it after second execution. Below is the sequence of the code execution as traced by break points, strange but true...
BackgroundWorker worker = sender as BackgroundWorker;
e.Result = MyTimeConsumingTask(e.Argument, worker, e);
Thread.Sleep(10000);
return true;
BackgroundWorker worker = sender as BackgroundWorker;
e.Result = MyTimeConsumingTask(e.Argument, worker, e);
Thread.Sleep(10000);
return true;
else if ((bool)e.Result)
|
|
|
|
|
Try using trace statements instead of watching it through the debugger, and put a breakpoint at the end of the OnCompleted method. When the breakpoint is hit, examine the trace statements.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
You're not accidentally adding another handler to DoWork are you?
bgWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWork);
bgWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWork);
If you do that, it will be called twice.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
Thanks Steve!
You were right, I checked the whole project for DoWork and found that the Visual Studio had already added the DoWorkEventHandler in its generated code InitializeComponent()
Now after removing it, works as expected.
|
|
|
|
|
I would like to upload file one by one using BackgroundWorker. But it seems the application using multi-thread to uplaod. Is there any methods like Thread.join on backgroundWorker?
Thanks,
Mimi
|
|
|
|
|
Do you want to wait till background worker finishes? Use waithandles. Call WaitOne() when process starts. Handle RunWorkerCompleted event and signal your waithandle.
|
|
|
|
|
can you show me the example how waithandles work with BackgroundWorker.
Thanks.
|
|
|
|
|
Implementing waithandles is trivial. Here is a console application.
class Program{
static EventWaitHandle handle = new AutoResetEvent(false);
static void Main(string[] args) {
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
worker.RunWorkerAsync();
Console.WriteLine("Main thread waiting");
handle.WaitOne();
Console.WriteLine("Main thread released.");
Console.Read();
}
static void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
Console.WriteLine("Worker finished. Releasing main thread");
handle.Set();
}
static void worker_DoWork(object sender, DoWorkEventArgs e) {
Thread.Sleep(1000);
}
} Hope it is clear now
|
|
|
|
|
That's because a BackgroundWorker is a thread. If you want to use a thread to upload a file (presumably to keep the UI responsive during the upload), a join is pointless.
Set your backgroundworker to report its progress, add the appropriate event handler, and add a control that's updated when the backgroundworker reports its progress.
If you want the program to not allow input during the upload, don't use a thread (or async upload).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
How do i compress and decompress an image using GDI+ JPEG methods?
|
|
|
|
|
You don't really 'compress' when you save as a jpeg. You are throwing out alot of data.
There is no way to uncompress a jpeg image. You can save it as a bitmap and its size will increase dramatically, but it will still have all the artifacts from the jpeg. If you want to 'compress' an image and keep the original quality, save it as a PNG or something.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I have a C# Windows form with a button on it. When the button click event occurs I open a new mail message and supply the mail reciepients and subject. When the user clicks the send button I want to retrieve the mail body for my app.
Is there a way to do this using the application.itemsend event? If so is there any sample code out there showing this.
Thanks!
|
|
|
|
|
hi is there any another method that API to loading FIB(header of Doc. file) i founde i must access to root storage so will access to FIB
i want to hiding data in unued sector
|
|
|
|