Click here to Skip to main content
15,887,812 members
Home / Discussions / C#
   

C#

 
AnswerRe: Run application until Tasks are finished? Pin
Dave Kreskowiak30-Aug-13 14:57
mveDave Kreskowiak30-Aug-13 14:57 
GeneralRe: Run application until Tasks are finished? Pin
Dralken30-Aug-13 15:16
Dralken30-Aug-13 15:16 
GeneralRe: Run application until Tasks are finished? Pin
Dave Kreskowiak30-Aug-13 15:28
mveDave Kreskowiak30-Aug-13 15:28 
GeneralRe: Run application until Tasks are finished? Pin
Dralken31-Aug-13 1:26
Dralken31-Aug-13 1:26 
GeneralRe: Run application until Tasks are finished? Pin
BillWoodruff1-Sep-13 19:51
professionalBillWoodruff1-Sep-13 19:51 
GeneralRe: Run application until Tasks are finished? Pin
Dralken1-Sep-13 20:40
Dralken1-Sep-13 20:40 
SuggestionRe: Run application until Tasks are finished? Pin
Keith L Robertson3-Sep-13 5:27
Keith L Robertson3-Sep-13 5:27 
QuestionHow to solve this error "safe handle has been closed"? Pin
vikash kumar NIIT29-Aug-13 23:16
vikash kumar NIIT29-Aug-13 23:16 
Hi all,

i am using code to disable a task in windows task scheduler.

here is my code
C#
TaskService ts = new TaskService(@"\\" + domain + "", "" + user + "", "" + domain + "", "" + passwo + "", true);

           ts = new TaskService();
           Task t = ts.GetTask(Task);
           if (t != null)
           {
               try
               {
                   if (t.Enabled)
                   {
                       t.Enabled = false;
                       t.RegisterChanges();

                   }
               }
               finally
               {
                   if (ts.Connected)
                   {
                       t.Stop();
                       ts.EndInit();

                   }
               }
           }


it is working fine but in the same application some more function is there when other function is running in between i am getting this error "safe handle has been closed".

i copied the stack trace and pasting here below:

" at System.Security.Principal.Win32.ImpersonateLoggedOnUser(SafeTokenHandle hToken)\r\n at System.Security.Principal.WindowsIdentity.SafeImpersonate(SafeTokenHandle userToken, WindowsIdentity wi, StackCrawlMark& stackMark)\r\n at System.Security.Principal.WindowsIdentity.Impersonate(StackCrawlMark& stackMark)\r\n at System.Security.SecurityContext.SetSecurityContext(SecurityContext sc, SecurityContext prevSecurityContext, StackCrawlMark& stackMark)\r\n at System.Threading.ExecutionContext.SetExecutionContext(ExecutionContext executionContext)\r\n at System.Threading.ExecutionContext.runTryCode(Object userData)\r\n at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading._TimerCallback.PerformTimerCallback(Object state)"

please solve this problem it is irritating me too much.

Thanks,
Hello Everybody

SuggestionRe: How to solve this error "safe handle has been closed"? Pin
Richard Deeming30-Aug-13 1:38
mveRichard Deeming30-Aug-13 1:38 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
vikash kumar NIIT30-Aug-13 1:50
vikash kumar NIIT30-Aug-13 1:50 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
davidstein30-Aug-13 3:06
davidstein30-Aug-13 3:06 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
Richard Deeming30-Aug-13 3:21
mveRichard Deeming30-Aug-13 3:21 
Questionhow to get balance by USSD commands? Pin
davidstein29-Aug-13 22:58
davidstein29-Aug-13 22:58 
SuggestionRe: how to get balance by USSD commands? Pin
Richard MacCutchan30-Aug-13 0:03
mveRichard MacCutchan30-Aug-13 0:03 
GeneralRe: how to get balance by USSD commands? Pin
davidstein30-Aug-13 1:04
davidstein30-Aug-13 1:04 
GeneralRe: how to get balance by USSD commands? Pin
Dave Kreskowiak30-Aug-13 2:42
mveDave Kreskowiak30-Aug-13 2:42 
GeneralRe: how to get balance by USSD commands? Pin
davidstein30-Aug-13 3:05
davidstein30-Aug-13 3:05 
GeneralRe: how to get balance by USSD commands? Pin
Richard MacCutchan30-Aug-13 3:27
mveRichard MacCutchan30-Aug-13 3:27 
GeneralRe: how to get balance by USSD commands? Pin
Dave Kreskowiak30-Aug-13 3:59
mveDave Kreskowiak30-Aug-13 3:59 
GeneralRe: how to get balance by USSD commands? Pin
davidstein30-Aug-13 8:27
davidstein30-Aug-13 8:27 
GeneralRe: how to get balance by USSD commands? Pin
Dave Kreskowiak30-Aug-13 12:45
mveDave Kreskowiak30-Aug-13 12:45 
Questionhow to writ code for percentage in windows application form Pin
ashwini dharamsale29-Aug-13 22:31
ashwini dharamsale29-Aug-13 22:31 
AnswerRe: how to writ code for percentage in windows application form Pin
Simon_Whale29-Aug-13 23:05
Simon_Whale29-Aug-13 23:05 
GeneralRe: how to writ code for percentage in windows application form Pin
ashwini dharamsale29-Aug-13 23:09
ashwini dharamsale29-Aug-13 23:09 
GeneralRe: how to writ code for percentage in windows application form Pin
Simon_Whale29-Aug-13 23:17
Simon_Whale29-Aug-13 23:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.