|
You can't achieve the result you're trying by using Thread.Abort(). When calling Abort() on a thread, if the thread is currently executing native code (or COM in this case), nothing will happen until the thread returns to managed code. At that point it will throw a ThreadAbortException.
I don't know of a non-hackish (and dangerous) way to achieve this result.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
How can i stop the COM from executing?What are my options?
|
|
|
|
|
Bassam, would reducing the thread's priority help? (Not sure if you can do this while it's in unmanaged code).
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I am not sure, i need to stop the execution of the COM and assign the thread to another COM process(user request).i am thinking of creating an exe that invokes the COM and assign the thread a function that launches that exe.When a thread aborts , i will kill the exe and hopefully stop the COM execution.Do you think that will work?Is there an easier solution?
|
|
|
|
|
Bassam Saoud wrote: Is there an easier solution?
If you have access to the COM source code, you could use a semaphore (or even a cheesy manual solution such as polling for a termination signal) to indicate to the COM server that it needs to abort. But I am grasping at straws here...
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
That requires redesigning all COMs that are already in production.I am still looking for solutions without changing the COM Source Codes.What are my options?I am ready to try anything!
|
|
|
|
|
You could also create a MTA COM component that spawns a native thread and the COM object. You could then add a method to that object to abort the native thread when you choose.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
How about the following (similar to Jared idea above): create an out-of-proc COM server that will start the dll. When you need to stop the dll execution just kill the out-of-proc server by killing its process. It should work, IMO.
|
|
|
|
|
If it is running in it's own process as COM+, you could kill the dllhost.exe process. Very un-slick, but an option if you need it.
|
|
|
|
|
Interesting idea but how do you determine the dllhost process that needed to be killed? The system creates it so you would have no way of knowing the process id. Or is there something that I do not know?
|
|
|
|
|
You compare a before and after of the process list when you create the COM object. Again, this obviously has some reliability problems. I think there's also a way of talking to the COM+ server and shutting it down there.
|
|
|
|
|
AndrewPeters wrote: reliability problems
I wonder what would happen if the wrong process would get killed?
|
|
|
|
|
I am invoking multiple COM objects with a thread assigned to each COM object initiated.If i kill the out-of-proc server, wouldnt that stop all DLLs from executing not only the one instance i need killed?
But again i am trying trying to wrap the COM invocation in an exe application and assign the exe launch to a thread.Hence every COM instance is invoked by a thread through the exe application.When i need to abort the thread i kill the exe process assined to the thread.Do you think that will work i.e killing the exe will it stop the DLL execution?Lets say it works , is there performance issues related?How can i solve this?
|
|
|
|
|
Hi All,
Windows Explorer generally remembers the setting of each folder viewed.There is one entry in the HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags for each folder.how I can know which entry corresponds to which folder, programmatically.Thanks in advance.
Rakesh
-- modified at 2:03 Saturday 31st December, 2005
|
|
|
|
|
There is no documented relationship between which bag under ShellNoRoam belongs to which folder. You actually have to go through the Shell's Namespace interface on the ShellFolder you want to get this information.
I hope you're familiar with the Win32 Shell API's. If not, Shell Basics[^].
From the MSDN Gospel:
Objects that support IShellFolder are usually created by other Shell folder objects. To retrieve a folder's IShellFolder interface, you normally start by calling SHGetDesktopFolder. This function returns a pointer to the desktop's IShellFolder interface. You can then use its methods to retrieve an IShellFolder interface for a particular namespace folder.
Note: IShellFolder methods only accept PIDLs that are relative to the folder. Some IShellFolder methods, such as IShellFolder::GetAttributesOf, only accept single-level PIDLs. In other words, the PIDL must contain only a single SHITEMID structure, plus the terminating NULL. When you enumerate the contents of a folder with IEnumIDList, you will receive PIDLs of this form. Other methods, such as IShellFolder::CompareIDs, accept multi-level PIDLs. These PIDLs can have multiple SHITEMID structures and identify objects one or more levels below the parent folder. Check the reference to be sure what type of PIDL can be accepted by a particular method.
You can make a quick check to see if what you want to do can be done using the desktop.ini file in each folder by checking out this[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave,
Thanks for your reply.Actually using the IShellFolder and IShellFolder2 interface was the first thing which i had tried.but i didn't have any success with them then i tried to get it through registry.Basically i want to know the sort order for a particular folder view if there is any.Hopefully by using IShellView or IShellFolder2 i can get some useful information.This is the code which i had tried.
IntPtr newPidl = IntPtr.Zero ;
IShellFolder ishFolder = null;
IntPtr ppvOut = IntPtr.Zero;
string path = @"C:\Documents and Settings\Administrator\Desktop\A";
if(Interop.SHGetDesktopFolder(ref ishFolder)==0)
{
// we have it:
int cParsed = 0;
int afItem = 0;
ishFolder.ParseDisplayName(
IntPtr.Zero,
IntPtr.Zero,
path,
out cParsed,
out newPidl,
out afItem);
IntPtr handle = IntPtr.Zero;
WIN32_FIND_DATA data = new WIN32_FIND_DATA();
handle = Class2.FindFirstFile(path,out data);
//here i am getting the error
ishFolder.CreateViewObject(handle,ref IID_IShellFolder2,out ppvOut);
******************************************************
but i was not able to get any folder even IShellFolder interface itself from the CreateViewObject
function.This is The error i got::
System.InvalidCastException: No such interface supported
at TestApplication.IShellFolder.CreateViewObject(IntPtr hwndOwner, Guid& riid, IntPtr& ppvOut)
How can i get IshellFolder2 or IShellView interface for any folder.what i am doing wrong here?
Also thanks for the .ini link but i don't think it is going to solve my problem.Any ideas will be greatly appreciated.Thanks in Advance.
Rakesh
|
|
|
|
|
I planed to start learning C#. Which is the best book to learn C# as beginner and also programmable.
N.Rajakumar B.E.,
Application Developer,
|
|
|
|
|
Professional C# by Wrox Publishers
Akif
|
|
|
|
|
please ,send me the C#.NET step by step programming.
signature:
chandrasekhar
|
|
|
|
|
You may wish to consider purchasing it yourself. That way the author will be compensated for the considerable time and effort put in to writing the book in the first place.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
|
|
|
|
|
Hi.
There are a variety of good books to learn C# besides the one just mentioned to you. Programming C# by Jesse Liberty is good, the same goes for C# Unleashed by Joe Mayo and the same goes for C# The complete reference by Herbert Schildt.
If you look them up on amazon you might be able to see their content there.
Good luck,
FJ
|
|
|
|
|
|
Hi,
My add-in will debug for a distribute program, so I need to set different break points to diff "Node"s. I insert new ones and remove old break points at runtime when node switchs, this is done successfully, but my program still stop at the old break points, and the break point's BreakPointLastHit property is null (because I remove old ones already).
what shall I do to stop my program at the new ones.
|
|
|
|
|
Hi
I have a simple WinForm I've created. With the following code:
//////////////////////////////////////////////////////////////
public void DrawXYAxes(Graphics g)
{
g.DrawLine(axisPen, xIndent, yIndent + 200, xIndent + 400, yIndent + 200);
g.DrawLine(axisPen, xIndent + 200, yIndent, xIndent + 200, yIndent + 400);
}
This will then draw X Y Axes on the form.
Let's say the screen coordinates at the drawn origin are "200, 200".
What's the most efficient way to get "200, 200" to display "0, 0"?
So now when I move the cursor around the Form it will have both positive and
negative axis coortinates?
ps--I know how to display the screen coordinates as text on the screen, I just can't seem to get the system to be correct....
Thanks very much......
|
|
|
|
|
I think that you may want to investigate Graphics.TranslateTransform() . If you translate the Graphics object by 200 left and 200 down, you'll have what you need, methinks. To see this in action, you can check out my recently published article Y(et)A(nother)TabControl in which I perform these kinds of transformations to translate the origin all over my control.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|