views:

205

answers:

1

Hello All,

i want to get list of all application or Threads attached with a process.For example when we open different window all run with explorer.exe or we open different window of mozila all are in firefox.exe. i have to check that if a window is all ready open no need to open this.and if it is in background or minimized then then activate the window.

+1  A: 

To get all processes

      Process.GetProcesses();

or

       Process.GetProcessByName("Name"); //To get a process

or

        Process.GetCurrentProcess()  //To Get the current running process

Once you get your process you have an attribute called Threads.

Is that what you are looking for?

Once you get the Process you can use ProcessName and once you get the ProcessThread you can use ID.

Nix
ya ,thanks, but unable to get exact name or id of thread?
Vivek
ProcessThread has an ID on it, and process has ProcessName.
Nix
ya,but id is unique for each new thread.I have to find if a thread (a window is already open) of similar type is already is started then no need to start a new thread.
Vivek
I dont understand what you are getting at. You want a way to find a thread, by something other than id? I would argue that you probably need a better way to control how you are spawning threads
Nix
@Nix,my problem starts form a concept in which i dynamically load assembly and invoke a method in that ..Assembly objAssembly = Assembly.LoadFrom(@AssemblyFile); Type type = objAssembly.GetType(methodname); var objVar = Activator.CreateInstance(type); type.InvokeMember("ClassName", BindingFlags.Default | BindingFlags.InvokeMethod, null, objVar, oSystemUser);
Vivek
mehtod that invoke this open a new window.(thread)each method is open by a menu.now i have to check if a thread (window) is already open then there is no need to open same window.
Vivek
I am assuming you can get the correct process, but have no clue which thread is which. I am suggesting that you need a design change, and you need something to create/manage threads(because processthread is not going to provide you what you need (thread).
Nix
@Nix,Thanks..let see what can i do...
Vivek