|
I'm creating a program for my school and I have the majority of the bugs fixed but I'm stuck on one part that I can seem to get the timer to stay active after the program is closed. This program allows the user to enter mins and seconds for a timer so they can complete tasks in time but each time the program is closed the timer resets to 0. Is there a way I can make it so maybe when they close the software it doesn't really close it but minimizes it so the timer can continue to run?
|
|
|
|
|
It depends on what you are actually trying to do with your timer: you can't set up a timer within your application and have it run after the app is closed, so it you are doing this to "time" an exam or similar, then it's totally the wrong approach as it's very simple to bypass - bring up task manager and terminate the app process.
So you need to think about exactly what you are trying to use the timer for: what purpose does it serve? What should happen when it expires? What if the use logs out? Turns off the computer? Runs two copies of the app?
There are ways - pretty simple ones - to say "this task must be completed by hh:mm today" and persist that between runs of the app, but that may not be appropriate, depending on your use case.
Similarly, there are ways to minimize the app when it's told to close - but those are nothing like infalible so again, it depends on your use case if that is appropriate.
And we have no idea what you are trying to do with this - we have no access to your system, and only get exactly what you type to work with!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Before we can answer your question, you really need to tell us what type of application this is. Is it a console application? A WPF application? WinForms? WinUI?
|
|
|
|
|
If you're using one of the Timer classes in .NET, you have a serious misunderstanding of how timers work and a serious design flaw in your program.
Any of the Timers you use in the .NET Framework are objects in your code. When your application quits, it's no longer in memory and all of the objects you allocated are destroyed, including the Timer. It doesn't "reset to 0". It's destroyed entirely!
|
|
|
|
|
You can "close" a (Windows) program; minimize (or maximize) it; or hide it, which includes moving it "off screen" or setting its .Visible property to false. Of all those, in your case, you do not want to "close" your program (because that "stops" it).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I am working with EFT solutions in the LSRetail LSOne POS, and one of my customers has an issue that I cannot figure out why happens.
I have a class that has the following declaration:
public class MyEFTService : EFTBase, IEFTService, IMyInterface
{
}
The IMyInterface interface is one I have added so I can execute some added functionality to the class from another location. I do that like this:
public IPosTransaction RunTask()
{
var service = Services.EFTService(entry);
var dxcpcEft = (IMyInterface)service;
}
The Services.EFTService(entry) call returns the instance of MyEFTService created during startup, which I then cast to my IMyInterface and I can then do the calls I need to. This works on my machine, on my testers machine, and any co-workers machine. But it's here my customer has an issue. When we try to cast the instance to the IMyInterface interface on his machine we get an InvalidCastException. In debug, if I look at the service variable and browse through the object information, I can see variables that only my version of EFTBase has and I then know that it does have the IMyInterface as well.
We also tried to execute service is IMyInterface in the immediate debug window of visual studio and it returns true. So, as far as I can see, the service variable DOES have the IMyInterface and visual studios Immediate debug window confirms it. We also tried to run service.GetType(), and that too returns information related to MyEFTService class:
{Name = "EFTService" FullName = "LSOne.Services.EFT.EFTService"}
Assembly: {LSOne.Services.EFT.MY_EFT, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
AssemblyQualifiedName: "LSOne.Services.EFT.MyEFTService, LSOne.Services.EFT.MY_EFT, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
Attributes: Public | BeforeFieldInit
BaseType: {Name = "EFTBase" FullName = "LSOne.Services.EFT.Common.EFTBase"}
ContainsGenericParameters: false
CustomAttributes: Count = 0
DeclaredConstructors: {System.Reflection.ConstructorInfo[1]}
DeclaredEvents: {System.Reflection.EventInfo[0]}
DeclaredFields: {System.Reflection.FieldInfo[15]}
DeclaredMembers: {System.Reflection.MemberInfo[75]}
DeclaredMethods: {System.Reflection.MethodInfo[52]}
DeclaredNestedTypes: {System.Reflection.TypeInfo.<get_DeclaredNestedTypes>d__23}
DeclaredProperties: {System.Reflection.PropertyInfo[3]}
DeclaringMethod: '((System.RuntimeType)service.GetType()).DeclaringMethod' threw an exception of type 'System.InvalidOperationException'
DeclaringType: null
FullName: "LSOne.Services.EFT.MyEFTService"
GUID: {2804dbd4-c09a-3951-820b-ce4db1b72a55}
GenericParameterAttributes: '((System.RuntimeType)service.GetType()).GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
GenericParameterPosition: '((System.RuntimeType)service.GetType()).GenericParameterPosition' threw an exception of type 'System.InvalidOperationException'
GenericTypeArguments: {System.Type[0]}
GenericTypeParameters: {System.Type[0]}
HasElementType: false
ImplementedInterfaces: {System.Type[3]}
IsAbstract: false
IsAnsiClass: true
IsArray: false
IsAutoClass: false
IsAutoLayout: true
IsByRef: false
IsCOMObject: false
IsClass: true
IsConstructedGenericType: false
IsContextful: false
IsEnum: false
IsExplicitLayout: false
IsGenericParameter: false
IsGenericType: false
IsGenericTypeDefinition: false
IsImport: false
IsInterface: false
IsLayoutSequential: false
IsMarshalByRef: false
IsNested: false
IsNestedAssembly: false
IsNestedFamANDAssem: false
IsNestedFamORAssem: false
IsNestedFamily: false
IsNestedPrivate: false
IsNestedPublic: false
IsNotPublic: false
IsPointer: false
IsPrimitive: false
IsPublic: true
IsSealed: false
IsSecurityCritical: true
IsSecuritySafeCritical: false
IsSecurityTransparent: false
IsSerializable: false
IsSpecialName: false
IsUnicodeClass: false
IsValueType: false
IsVisible: true
MemberType: TypeInfo
MetadataToken: 33554438
Module (System.Reflection.MemberInfo): {LSOne.Services.EFT.MY_EFT.dll}
Module: {LSOne.Services.EFT.MY_EFT.dll}
Name: "MyEFTService"
Namespace: "LSOne.Services.EFT"
ReflectedType: null
StructLayoutAttribute: {System.Runtime.InteropServices.StructLayoutAttribute}
TypeHandle: {System.RuntimeTypeHandle}
TypeInitializer: null
UnderlyingSystemType: {Name = "EFTService" FullName = "LSOne.Services.EFT.EFTService"}
But when we try to code line that casts to the interface, the code fails with an InvalidCastException. We briefly thought that the POS system might not have loaded MyEftService correctly, but we can do operations on it without any issue, so that is not the case.
How come that, on my customer's machine, it cannot cast the service variable to IMyInterface, when all investigations indicate that the service variable does contain an object that inherits IMyInterface, and it works on any other machine? Do you have any suggestions that we can try out?
I am aware that the code is not particularly "safe" in terms of casting and should probably be protected some more. That is in the works.
|
|
|
|
|
I'd start by checking if the customer has all the right dependencies - if the interface or class is declared in a separate assembly (and it probably should be) then a version mismatch could cause the problem.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I thought I did confirm the versions, but it does look like there is a version mismatch with at least some files. I will update when I have more information.
|
|
|
|
|
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Upon further research, it became clear that the versions of the POS system did not match the expected version. We transferred the source code over to the customer so he could build the files with his version and to great care in deleting all other versions of the affected DLL. We still get the same results. I also found the version on my machine that they actually got from me and ran a test on my machine, and it works without problems.
So now to rule out a problem on the customer's end, he is currently sending me the entire software catalogue with my file changes to see if it crashes on my machine. If it fails, it's something in his project. If it does not fail... then I actually don't know. I will keep you posted.
|
|
|
|
|
Sound like you're going to need a site visit with a copy of VS ... I hate those.
I once spent a week sitting quietly in a library waiting for software to go wrong, only to find on the Friday it was a hardware problem: they had a laminator they used to seal new user badges which spat so much noise back down the mains lead it fritzed out the PSU.
Still, it was on expenses, and the hotel bar was good!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Easy way to prevent it in the future; make a hash from all that you build.
Do not confirm the versions, confirm the resulting hash.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
0) Ensure than their machine is up to date on their Windows updates.
1) Have the customer uninstall it (and all older versions), and reinstall it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I want to get the control for passing the ticket number in the search bar and update the work notes field and need to change the state field to resolved and click on the update button in servicenow. I have tried but it shows (no such element found exception). kindly help me in this case. I have attached the sample code that I have tried.I have used seleniumc#. I have tried many ways but still getting no such element found exception. kindly some one help me in this case.I want in c#.
Below one is the sample code which i have tried
IWebElement elem = driver.FindElement(By.Id("sysparm_search"));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView();", elem);
elem.SendKeys("INC0008111");
elem.SendKeys(Keys.Enter);
WebDriverWait wait2 = new WebDriverWait(driver,TimeSpan.FromSeconds(20));
wait.Until(ExpectedConditions.ElementExists(By.Id("activity-stream-textarea")))
wait2.SendKeys("closing the request");
SelectElement se = new
SelectElement(driver.FindElement(By.Name("incident.state")));
se.SelectByIndex(3); IWebElement ele4 =
driver.FindElement(By.Id("resolve_incident")); ele4.Click();
|
|
|
|
|
The first thing to do is to use the debugger to find out which element is not found.
Then you can start looking through your design to find out why: but since we have no access to your code while it is running or your design at all there is nothing we can do to help.
Just "trying many ways" doesn't help you - you need to think logically and gather information before you start modifying code. Without doing that, you are just guessing, and that isn't an efficient 9or effective) way to fix any problem! Gathering information on a problem is what the debugger is there for - so use it!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In my project, i was used a control of PropertyGrid, and i bind a object(the instance of my class). The drop-down list-box item of propertygrid could be drop down only once. there is nothing showing when i click the drop-down button again.(the list item just like bool, enum variables) And surprisedly, i can't close this window.
So, help me, please...
a poor guy diging C#
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So start with the code: what are you doing when it drops down? How are you binding it? What does your class contain? What is it derived from? Do you override ToString? Anything else that might be relevant?
Only you can look at things like this: we can have no idea without much, much better information!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Works for me, even on Linux using mono.
Can you post some code to reproduce the problem?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I have requirement where we have 2 exe's. When first exe started then I have to call method of second exe which will do some process. once that process is completed then it again intimates first exe that my work is done. you can resume your work.
Note: I do not want to use sockets. Most preferred way is like Mutex or Semaphore.
Any help will be much appreciated.
|
|
|
|
|
|
|
Source of Integral Calculation Program Using Random Numbers Generation (Kaufman)
with c#,c++,Python
|
|
|
|
|
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. We are not a "code to order" service!
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I was given a medium sized app, about 50,000 line total. It will not shut down on its own. You either have to kill it the debugger or go to Task Manager to kill it there.
I have hit things like this before. You create a child and then kill the parent. You have lost the handle to the child and cannot close it. The app hangs when shutting down. Before I was building the program and knew when this happened. I only had to backtrack a little bit to find the problem.
Now I have something written by someone else. When you kill the app even in the debugger you loose the stack panel. How can I find what the offender is?
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
If it's a windows app (implying there is a windows collections), you see if there are are "hidden" windows hanging around (by querying the collection).
If it's "looping" in managed code, it will show where if you "suspend" in Debug (not "cancel").
If it's hanging in "unmanaged" code, it gets more interesting.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|