For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
Another way is to decompile the System-assembly which contains the method and copy that implementation into a new method to make up for the missing Array.Reverse() method. Alternative, I would use Enumerable.Reverse as an array is just another enumerable.
No, not the answer the interviewer is wanting, but correct nonetheless and the answer is at least equally valuable as the question
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
Here is my problem: I am developping a game engine in C # (Winform). The program icon is correctly managed. I want to modify this icon, once the program launched, dynamically, to reflect the choice of the game that has just taken place. The process is done correctly, EXCEPT that it only works if the executable has been launched directly. On the other hand, if the launch was made from a shortcut, (choice in the Start Menu, for example, or redirection icon on the desktop), the icon in the taskbar remains obstinately blocked on the program icon. I tested this program under XP, where it reacts to my convenience (dynamic change of the correct icon) and under W7 or W10 where the update of this icon does not happen.
Here is the code that I use for this function:
Bitmap b = null;
b = new Bitmap (Fen.Chm + Fen.Gam + "\\" + f);
IntPtr p = b.GetHicon ();
Icon = Icon.FromHandle (p);
catch (Exception x)
I could not find the solution on any site I visited. Does anyone have a track?
i need a concept that i want to develop a winform apps which will be running as invisible apps in windows OS. when some one try to stop this apps from task manager then a password dialog box will appear. if user could provide right password then apps will be stored or otherwise apps will not be stopped.
please share the idea to show dialog box when user try to stop my apps from task manager.
Besides the other comments also keep in mind that there are three (at least) exceptions that will terminate the VM. And no way to stop that. Stack overflow was the only one that I really expected to see.
(Not a question, not a Tip/Trick in my eyes. Wanted to share and didn't see a better place for it.)
I'm implementing a write-ahead log (WAL) for an application and was searching for an answer on how to make sure a file actually gets written to disk when I close the FileStream and doesn't linger in one of the intermediary I/O caches, being vulnerable to system power loss.
There's a lot of confusion "in the webs" about which way is actually working:
- FileOptions.WriteThrough / FILE_FLAG_WRITE_THROUGH
- FileStream.Flush(flushToDisk: true)
tl;dr: FlushFileBuffers is the way to go on Windows 8 and newer (also best bet on Win7), FileOptions.WriteThrough might work as well but probably not, blame the storage device manufacturers.
Looking into the source of FileStream (.NET 4.7) I saw that all FileStream.Flush(flushToDisk: true) actually does is to call Win32.FlushFileBuffers. On my Google journey I found "hints" that this might not always have been the case, so if you need it, you should look into the source of the .NET version you're using.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
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.