A Windows Service uses too many threads. I added some logging to find out more. Sadly, there's little support from the .Net framework. ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads); starts with some 32760 workerThreads, and 1000 completionThreads, resp.
After a few hours, workerThreads went down to 31817, i.e. almost 1000 managed threads are in use. What are they doing? There's no way to find out (you may find some workaround where you place the threads you create into some collection, and later analyze that collection, but that fails when you also use Parellel.ForEach or Task.Run).
Well, there is another possibility. Try ProcessThreadCollection currentThreads = Process.GetCurrentProcess().Threads; That will give you a list of non-manged threads.
That Windows Service starts with some 20 of them. After a few hours, I detect 3828, i.e. about 4 non-managed threads for each managed thread...
Now I can ask each of them when it started, what is its priority, what it is doing currently, and why it is waiting. Yes, for almost all of them the current state is Wait. And the WaitReason is in most cases UserRequest.
So my question is: what are those threads actually doing? There is no User Interface, even no command line associated with that executable: it is a Windows Service...
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
I want to run an exe or two from inside a windows form. now, i have found a few examples of these on this board, but, I want to be able to keep the exe inside the boundary of the actual form I create in C#. I am using Visual Studio 2013.
thanks very much for your help,
Lancaster, Calif. USA
Perhaps you want to look into the MDI (Multiple-Document Interface), this will load the form "inside" the form. The core concept is to load multiple documents inside the window, and they each run inside their own window.
However, if you wanted something like a UserControl type object that mimics the WinForm and display a complete Form object, that I am unsure that you can do. That might be possible through Page, or Window object in WPF to be hosted inside a Frame, but I am unsure as to whether WinForms technology had that much abstraction.
An EXE can do anything. It can be a Windows service, a console application, something without any UI at all, a GUI app (WinForm, WPF, Win32, ...) opening one or more windows in whatever size it pleases.
If it is a console app, then instead of trying to place the console in the correct location you can launch the process with all output redirected to your program. Then you have to read these outputs and put them into one or another text display on your form.
If it is a GUI program of one or another kind you can send messages to it telling it to move/resize the window. Basically you can pump the same messages into it programmatically as it would have gotten if the user is moving/resizing the window. Of course, the window can always choose to say "no".
Not a lot of detail on how to do it, but in case I guessed right on what you are trying to do, at least a starting point for what to google.
My recommendation would be to consider DataGrid to be used here. DataGrid supports this kind of behavior, all you would need to do in order to change the columns would be to change the data source. Instead of having to manage and maintain a ListView control, and then handle the change yourself, DataGrid can really make things simpler and DataGrid also provides the best suitable control for that data type; combobox for enum, textbox for string, checkbox for bool etc.
The Car does implement an action (set the speed value), but that is irrelevant. Bottom line, the Car needs to be a Vehicle and as a vehicle in must be able to perform an action but the action is dependent of the type of vehicle:
Vehicle<Actions> myVehicle = new Car();
Vehicle<Actions> myVehicle2 = new Airplane
We aren't here as a code-to-order service: for that you would need Freelancer.com.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
So either pay someone to do it, or learn how to write it yourself. We aren't here to do it for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!