15,891,431 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 11709930 (Top 15 by date)
Member 11709930
13-Nov-19 15:01pm
View
Appreciate your help MadMyche as I'm way out of my experience depth with this.
Member 11709930
13-Nov-19 14:35pm
View
I agree with that up to a point.
In my case, I am restricting users so as to avoid having to buy a large number of SQL CAL's.
Member 11709930
12-Nov-19 18:40pm
View
Thanks but I'm after the Forms Timeout which logs off the user.
Session timeout is somewhat different.
Member 11709930
23-May-19 17:50pm
View
Thanks Gerry, that's a great start and has got me moving.
Unfortunately SendKeys won't work for me as there no guarantee what the active window will be when the timer times out. Also there my be a few child windows open via the PrintDialog.
I think I need a way to find the HWND's for the Dialog and its children, then hit them with the user32.dll DestroyWindow
Member 11709930
1-Mar-16 21:08pm
View
Brilliant. Problem solved and I've learnt a bit more.
thanks
Member 11709930
25-Feb-16 16:17pm
View
Thats what I've gathered...
Found I can add a timeout so I've altered the Wait routine so it won't just sit there forever -
public void Wait()
{
bool finished = thread.Join(5000);
if (!finished)
thread.Abort();
}
And with Daves suggestion below, I've added a process kill into the Main so the app will die for me.
Process currentProcess = Process.GetCurrentProcess();
if (!currentProcess.HasExited)
currentProcess.Kill();
I realise its not ideal but will do until I can understand the myriad of threads this thing uses.
Member 11709930
25-Feb-16 16:06pm
View
I have this in the main loop-
ConsoleKeyInfo cki;
cki = Console.ReadKey();
if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
{
if (cki.Key == ConsoleKey.D)
// do stuff
{}
}
however this seems to be absorbing the windows message as it never fires the ctrlBreak handler whilst this is in place.
I didn't write the original app but I believe console was used for outright speed. This thing runs a heap of multithreading in a real time stock market application.
Member 11709930
25-Feb-16 15:59pm
View
Thanks Jochen
So CTRL_BREAK_EVENT, becomes CTRL_BREAK_EVENT=1, by default. Didn't know that and explains things nicely.
Member 11709930
24-Feb-16 19:53pm
View
Seems there is a line limit hence clipped response. Here's the rest-
public void Wait()
{
thread.Join();
}
Ok, hope some of that makes sense.
It seems there is a problem with thread.Join() for one of the threads. When this is reached, stepping is dumped and the console window sits there with a blinking cursor. I tried surrounding it with a Try/Catch but nothing is caught and the code does not step to the lines below.
If I now hit CTL_C again, the app exits immediately.
Think my question now is, how do I debug thread.join ?
Member 11709930
24-Feb-16 19:52pm
View
It would start again via Windows Scheduler.
Your assumptions are basically correct. I tried heading off the loop but the problems seem to lie in some of the threads not closing.
I've put more time into stepping through the code and there is CTL_C and CTL_BREAK handling in place-
private static bool TermHandlerRoutine(CtrlTypes dwCtrlType)
{
switch (dwCtrlType)
{ //no break so all close events handled same
case CtrlTypes.CTRL_CLOSE_EVENT:
case CtrlTypes.CTRL_BREAK_EVENT:
case CtrlTypes.CTRL_SHUTDOWN_EVENT:
case CtrlTypes.CTRL_C_EVENT:
terminated = true;
return true;
}
return false;
}
'terminated = true;' is detected by the loop which then fires this to close off process console handlers -
public static void Exit()
{
if (!initialized)
{
return;
}
// Unregister each callback delegate that the list contains
for (int i = 0; i < callbacks.Count; i++)
{
SetConsoleCtrlHandler(callbacks[i], false);
}
callbacks.Clear();
initialized = false;
terminated = true;
}
That gets us out of the loop where we initiate a thread cleanup -
private void Cleanup()
{
// Stop SessionClients
foreach (var item in sessionClients)
{
if (item.Value != null)
{
item.Value.Stop();
}
}
// Wait for SessionClients to terminate
foreach (var item in sessionClients)
{
if (item.Value != null)
{
try
{
item.Value.Wait();
}
catch (System.Exception ex)
{
Console.Write(ex);
}
}
}
sessionClients.Clear();
if (appLoggerMonitor != null)
{
appLoggerMonitor.Destroy();
appLoggerMonitor = null;
}
if (appLogger != null)
{
appLogger.Release();
appLogger = null;
}
if (eventQueue != null)
{
while (eventQueue.HasActiveEventStreams)
{
eventQueue.Dispatch(-1);
}
eventQueue.Destroy();
eventQueue = null;
}
if (rfaConfigDB != null)
{
rfaConfigDB.Release();
rfaConfigDB = null;
}
if (appConfigDB != null)
{
appConfigDB.Release();
appConfigDB = null;
}
// Uninitialise Context
if (!Context.Uninitialize() && Context.InitializedCount == 0)
{
// report problem if and ONLY if Context.Uninitialize() returned false
// AND Context.InitializedCount returns zero;
// if Context.InitializedCount returns more than zero, RFA did not attempt to uninitialize its context
Utils.ReportError("Application", configClient.ConfigurationClientName, "RFA Context fails to uninitialize ... ");
}
AppUtil.CleanupLog();
eventQueueSemaphore.Release();
eventQueueSemaphore = null;
}
From this, item.Value.Stop() and item.Value.Wait() fire these-
public void Stop()
{
try
{
stopping = true;
thread.Abort();
}
catch (System.Exception)
{
}
}
public void Wait()
{
Member 11709930
24-Feb-16 15:48pm
View
As I said, C is not my thing and I do not have the luxury of time at this point to do things properly.
I need something that will dump the app in the same way that clicking the X does. That makes the boss happy and buys me the time to understand whats going on in this thing and do it properly.
Member 11709930
23-Feb-16 18:06pm
View
Thanks, This app never completes. Runs 24/7 until manually closed. I've updated the original description to try and explain things better.
Member 11709930
23-Feb-16 16:57pm
View
Garth, I've updated the original question to try and explain some of this.
I guess "terminate it with extreme predjudice !" is what I need for now until I can understand the threads involved and shut down nicely.
Member 11709930
17-Feb-16 18:05pm
View
Not sure what you mean?
The chart type is 'area'
chart1.Series["Change"].ChartType = SeriesChartType.Area;
Member 11709930
15-Feb-16 21:50pm
View
This the MS Chart Controls for dot net.
http://www.microsoft.com/en-us/download/details.aspx?id=14422
I'll have read of the links, thanks
Show More