|
I am basically passing a path to a file.
Target application just check whether file exists, if does not then create that file.
|
|
|
|
|
PankajB wrote: Target application just check whether file exists, if does not then create that file.
You can as well create the file from the calling application as well. Why are you needing to have an executable solely for this? Or is there anything else? If the file copying takes too long and that leaves you with a frozen UI, just spawn a thread. Can't you?
You haven't answered my question: Is the target application handling the command line passed on to it? Without that being done, how will it display the command line?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
PankajB wrote: ABC.exe application got launched but text "Hello" never got displayed on the console.
Why would it be displayed on the console ? Are you retrieving it in the code of your application and prining the argument ? If yes, it's the argument at index 1, and not 0 that you have to use (the first argument is always the path to your application).
PankajB wrote: In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that.
Just pass the CString object.
|
|
|
|
|
Does your ABC.exe application correctly print it's first argument if launched by command line?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Let me provide few details...
1. Lets say ABC.exe just cout the text provided as an argument.
2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen.
3. if I call the same application like
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);
...it does not
Just FYI, ABC.exe is a Console based Application
|
|
|
|
|
Is the calling application also a console app? If not, does it open a new console window?
|
|
|
|
|
You must show us the target application's code, where you've handled the command line passed on to it.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\carlo.pallini\\ABC.exe", L"Hello", NULL, SW_SHOW);
works fine with my ABC.exe app...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: works fine with my ABC.exe app...
You must have the final release. I tried it with Beta 3 of abc.exe and the output was "Get lost" instead of "Hello"...
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
PankajB wrote: ABC.exe application got launched but text "Hello" never got displayed on the console.
Does the console window open at all?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Recently I found a code-snippet in C++ on wikipedia. It's used to work with CUDA:
http://en.wikipedia.org/wiki/CUDA[^]
In the last line of
dim3 blockDim(16, 16, 1);
dim3 gridDim(width / blockDim.x, height / blockDim.y, 1);
kernel<<< gridDim, blockDim, 0 >>>(d_odata, width, height);
they are using these operators (or whatever) with "kernel" being a function:
__global__ void kernel(float* odata, int height, int width)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
float c = texfetch(tex, x, y);
odata[y*width+x] = c;
}
What's the purpose for <<< and >>>? Thx for your answer!
|
|
|
|
|
from the CUDA dev guide[^]:
kernel <<< X, Y >>> (...)
defines a grid of X x Y threads which will execute in parallel
|
|
|
|
|
Hi,
I have created the thread using AfxBeginThread(); function. Now my problem is
1. How to check wheather Thread is running?
2. If it is running then stop/kill the thread.
This I will put in the destructor of class (which starts the thread) to do error handling.
How to do this?
Mike
|
|
|
|
|
See [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the link given.
So now I used it like following.
CWinThread * myWorkerThread;
myWorkerThread = AfxBeginThread(run, this);
In ~Destructor()
{
DWORD result =WaitForSingleObject(myWorkerThread->m_hThread,0);
if(result == WAIT_OBJECT_0)
delete myWorkerThread;
}
Is this is the correct apporch to do this?
Mike
|
|
|
|
|
No, because you don't stop the thread. So, how can it stop ?
Usually, to stop a thread you set a flag to false and this flag is constantly checked within your thread function. Once it is false, the function exits, which stops the thread.
But I guess everything is described in the article Carlo gave to you.
|
|
|
|
|
Cedric Moonen wrote: Usually, to stop a thread you set a flag to false and this flag is constantly checked within your thread function. Once it is false, the function exits, which stops the thread.
I'll be surprised if you are doing such a thing. What about the usage of Events with WaitForWhatever functions? Polling for a boolean is not the best approach, IMO, and definitely shouldn't be suggested to a rookie programmer. Not to mention that you will need to then explain the OP what optimization is and why does the optimizer have to be prevented from optimizing this particular boolean variable, and then there comes volatile ness, and ...
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Yes, sure. But even if you are using events to signal your thread that "data is available for processing", you still need a way to tell the thread that it should stop. Otherwise, having a thread that just wait on an event and stops when the event is signaled is a bit pointless.
But as I said in my message, it was a rough advice as everything is clearly explained in the article. My point was that you need a way to tell the thread that it's job is done, and usually you do this using a flag.
|
|
|
|
|
At times, it gets ugly with a boolean and I use two events, and two WaitFor... functions one after another. The first one checks if the thread should shut down, and the second one checks if there's data for processing and proceeds if there is. Based on the requirements, the events may be manual or auto reset. Threads are a fascinating thing, aren't they?
My reply was based on an assumption that you used a boolean for both. I was not kinda terrified.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
As a side note to Cédric reply, ponder the usage of the m_bAutoDelete flag. Bottom line: read carefully the article I linked.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You need not (and in most cases, MUST NOT) be delete ing a CWinThread object. It cleans up its own mess, unless you change the default value of m_bAutoDelete variable before the thread starts. And if you're thinking of changing the value of m_bAutoDelete , I can almost confidently tell that your approach is wrong (it is so, in 90% of the cases). If you knew what m_bAutoDelete is, you won't be asking here on how to shut down a thread gracefully.
Fixed typo!
It is a crappy thing, but it's life -^ Carlo Pallini
modified on Thursday, April 30, 2009 4:50 AM
|
|
|
|
|
|
Well, I am not contradicting the article, but most code that I've reviewed through, especially written by inexperienced programmers, which were reported 'not working' and had memory leaks, had the default value of m_bAutoDelete was manually changed for absolutely no sane reasons. Therefore my comment. I remember having posted one of such horrible codes in the coding horror board (or at thedailywtf), if I'm right.
It is a crappy thing, but it's life -^ Carlo Pallini
modified on Thursday, April 30, 2009 4:48 AM
|
|
|
|
|
I know, I know, I know.....
I've modified my previous post even before you replied.
You were right in first place Rajesh. I jumped to conclusions from your discussion with Cédric.
I'll just put a sock in it now...
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|