Pause Time in Windows [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am trying pause time using C#/.NET. I am able to set the time but I would like to set the time to pause.
Does anyone know how to do this?
Command Prompt suggestions would also be helpful.
I'm using Visual Studio 2010 if that matters.

For testing? or real life?
For testing you can mock DateTime.Now (although it is easier to have an IClock interface). For real usage - I just wouldn't.
Or do you just mean Thread.Sleep?

I think you are talking about stopping windows time, I imagine this is a not a feature of windows to do this.
What are you actually tryting to achieve (other than break windows) there may be alternate solutions.

Well, I'm not sure why you'd want to do this, but, since there is no such thing as a 'PauseTime' function in windows, why don't you just have a service that marks the current time, and then continously sets the system time to that start time. That should achieve the effect of keeping the system time the same.

If you need to find out elapsed time for some debugging work, there's the System.Diagnotics.Stopwatch class. The page on MSDN has some decent examples on how to use it. I don't know what type of precision you're looking for, so maybe this isn't the class to use if you're looking for high performance timing diagnostics.
Hope this helps!

Related

Re-run c# application after delay of 5 seconds [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
On clicking directly my c# application.exe file, i am running my application and its process in task manager appears if that process on certain condition kills my application stops. What i want is to re run the application after delay of 5 seconds by it self.
You cannot. That process is gone. What you can do is start a second process with you first, most commonly called a "watchdog" or "guard", to scan for your first process and if it does not find it, start it. It's not foolproof though, somebody could just as easily kill that process, too. It's just another layer.
Advice on how to implement that is far to broad for this format, I suggest you read some good articles on it, try to implement it and come here when you find yourself stuck at a specific problem.
Although my answer might not be that helpful, and also this question isn't a kind related to coding issues, but I suppose, using Windows Task Scheduler might work out for you, as you can add various triggers to your application and repeat your task after any set amount of time.
Hope it helps. Thanks

Real time use of abstract, sealed and static class [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
If I've some common functionality that I've to keep in a class, so will I go for static, sealed or abstract class...Does all these types of classes serve the purpose of keeping the common functionality together...where actually the difference lies when I've to go for one
abstract, sealed, static has nothing to do with real time development. It has to do with bring structure within your software, so that the functionality implemented in classes can and should be used in the right way.
After some comments i think this:
I think you can only learn this, by doing it. There isn't a book or epub that will explain you how to do programming. They will show the syntax and some examples. It will be trial and error. Every day you'll face a new challenge.
You'll have to practice it. The best advise is, look what others already created and try to imagine why did they wrote/solve it that way.
I can explain what a static/sealed/abstract class is/does, but it doesn't learn you when to use it.
Back to the question: Define 'real time'.. I think that static/abstract/sealed should NOT be decisive on how you write your 'real-time' software. If you are 'scared' about performance on this level, C# should not be your choise. I would write c++ or if you want a real challenge, try to beat the compilers with asm ;-)
I think you won't measure the 'overhead'
So, use abstract/static/sealed in a right way, so your future collega's/you can read/maintain it.
I use C# for communication (tcp/ip) between a windows computer and a PLC (with delta robots). But it's far from realtime. It's fast enough to keep many robot working with > 100 messages per second.

How to override other windows application's elements? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Can you please point me into the right direction?
I want to edit other application textbox or click, programmatically. For example, in a web sites, I can edit elements and invoke button clicks.
I have no idea how to do this, but I can move mouse and use keyboard run time is it possible to edit other application's textbox ?
I have C++, VB.NET, and C# knowledge - any suggestions or sample code?
Thanks.
There is no easy way to do this, but it is possible. You will dig through the Win32 Api to get what you need. There will be a lot code needed for this, too much to put in sample here.
You will need to start with finding the window you want. This could be accomplished with FindWindowEx. When you have the window, you can enumerate the child controls using EnumChildWindows.
When you finally get the handle to the control you need, you can hook up to the windows message subsystem and send a WM_SETTEXT message using the SendMessage function. There is a wrapper function available: SetWindowText but the documentation clearly states that it will NOT work for windows of other applications.
Be prepared for a lot of digging around in the Win Api. You will probably run into issues regarding security in newer windows OS's. When you get it to run the functionality will be highly depending on the OS, UAC settings etc.
I remember doing this once, 15 years ago in Windows 98, even then it was problematic! So good luck!

Is it possible to profile line-by-line in .NET? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a bit of an interesting question here about performance and was wondering if there was any way to do what I want to do:
I'm dealing with a large code-base (10,000+ lines), I want to run the code and get a visual analysis of what lines takes up the most time in the code. Like for example, is there anything that can highlight the lines of code that take up the longest amounts of time in .NET and/or give you a time spent on each line? In my mind, I'm visualizing something simple, like a green, yellow, and red highlight for each line of code and perhaps an amount of time that tells you how long each line took to run.
One way to get times would be through the Stopwatch, but its such a pain to have to have to add Stopwatches over and over again. How could I go about profiling my codebase like this? Does Visual Studio or .NET have anything out of the box for this?
Edit: Thanks to Patrick, I found out about ANTS, which does exactly what I wanted above (also shows HOT! lines in red in another window - lines that take up the most time...FYI: this isn't a profiler advertisement; I just required a line-by-line profiler for my needs and this does the trick so take it or leave it):
It's called a profiler, and there are many of them.
Some Visual Studio versions come with built-in analysis tools. Another tool I commonly use is ANTS Performance Profiler.
They sample which method is active (sampling), or even collect info on a per line / statement basis (instrumentation), depending on the settings used. You can use that to check what lines are most commonly used, or what lines consume most time each.
As a sample, take a look at the images in my question regarding statistics acquired from profiling.

Ideas for a windows desktop application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am starting to make my own apps and publishing them. The problem I face is that my apps are mainly for my purposes. What are some problems that you face while in windows? I need some desktop application ideas that are simple but helpful.
Rather than giving you a fish, I will humbly try and teach you how to fish:
Take a blank sheet of paper and write out as clearly as you can the problem that you want to tackle. Clarity is key because clarity of purpose gets your mind focused on what you are really trying to accomplish.
Think of at least 20 ideas and write them down on that once blank paper. Let your mind really flow and give up worrying about whether your ideas are practical or what other people will think about them.
Read over your list and determine which ones actually are good ideas. You might want to put the list away for a while and then take it out the next day to see if you still think those ideas pass whatever test you have for your ideas.
Lather, rinse, repeat.
Note that I don't necessarily know that I have a problem until you show me that I have a problem, and then show me how to fix it. Personally I think computers are still too hard to use, and I'm a programmer. Because my work life is so complex I like software and gadgets that are simple and elegant. MP3 players existed long before the iPod came out, but the iPod was able to get the mix right.
http://hubpages.com/hub/How-to-Come-Up-with-Good-Ideas

Categories

Resources