Click here to Skip to main content
15,920,383 members
Home / Discussions / C#
   

C#

 
AnswerRe: Entity Data Model Pin
Dave Kreskowiak10-Apr-15 15:55
mveDave Kreskowiak10-Apr-15 15:55 
GeneralRe: Entity Data Model Pin
jkirkerx12-Apr-15 8:05
professionaljkirkerx12-Apr-15 8:05 
AnswerOk, How about this? Pin
jkirkerx12-Apr-15 13:55
professionaljkirkerx12-Apr-15 13:55 
QuestionChanging a Struct Property Value Pin
Kevin Marois10-Apr-15 11:01
professionalKevin Marois10-Apr-15 11:01 
AnswerRe: Changing a Struct Property Value PinPopular
harold aptroot10-Apr-15 12:31
harold aptroot10-Apr-15 12:31 
AnswerRe: Changing a Struct Property Value Pin
OriginalGriff10-Apr-15 22:03
mveOriginalGriff10-Apr-15 22:03 
AnswerRe: Changing a Struct Property Value Pin
BillWoodruff10-Apr-15 22:53
professionalBillWoodruff10-Apr-15 22:53 
GeneralRe: Changing a Struct Property Value Pin
Richard Deeming13-Apr-15 1:31
mveRichard Deeming13-Apr-15 1:31 
GeneralRe: Changing a Struct Property Value Pin
BillWoodruff13-Apr-15 1:49
professionalBillWoodruff13-Apr-15 1:49 
GeneralRe: Changing a Struct Property Value Pin
Richard Deeming13-Apr-15 2:02
mveRichard Deeming13-Apr-15 2:02 
GeneralRe: Changing a Struct Property Value Pin
Kevin Marois13-Apr-15 3:06
professionalKevin Marois13-Apr-15 3:06 
GeneralRe: Changing a Struct Property Value Pin
Richard Deeming13-Apr-15 4:12
mveRichard Deeming13-Apr-15 4:12 
QuestionC# Memory Leak Question Pin
Kevin Marois10-Apr-15 10:45
professionalKevin Marois10-Apr-15 10:45 
AnswerRe: C# Memory Leak Question Pin
jschell10-Apr-15 11:36
jschell10-Apr-15 11:36 
GeneralRe: C# Memory Leak Question Pin
Kevin Marois13-Apr-15 3:13
professionalKevin Marois13-Apr-15 3:13 
QuestionEasy Way to Display Multilingual Tooltip and Message Box Pin
Felix Obere10-Apr-15 10:03
Felix Obere10-Apr-15 10:03 
Questionconvert piece of code from C++ to C# Pin
MrKBA10-Apr-15 8:25
MrKBA10-Apr-15 8:25 
AnswerRe: convert piece of code from C++ to C# Pin
RedDk12-Apr-15 16:49
RedDk12-Apr-15 16:49 
Questionsingle quote inside double quote in C# ASP.NET Pin
Rajeshkunwar2510-Apr-15 3:42
Rajeshkunwar2510-Apr-15 3:42 
AnswerRe: single quote inside double quote in C# ASP.NET Pin
OriginalGriff10-Apr-15 3:57
mveOriginalGriff10-Apr-15 3:57 
QuestionI can't get my splash screen to close Pin
jkirkerx9-Apr-15 11:00
professionaljkirkerx9-Apr-15 11:00 
AnswerRe: I can't get my splash screen to close Pin
Herman<T>.Instance9-Apr-15 23:54
Herman<T>.Instance9-Apr-15 23:54 
GeneralRe: I can't get my splash screen to close Pin
jkirkerx10-Apr-15 6:25
professionaljkirkerx10-Apr-15 6:25 
AnswerRe: I can't get my splash screen to close Pin
Richard MacCutchan10-Apr-15 2:20
mveRichard MacCutchan10-Apr-15 2:20 
A few changes to your FormSplash should make it work.

add a delegate to your class to handle the form closing
C#
delegate void CloseDelegate();

Add a method to handle the delegated form closing in a thread safe manner:
C#
void DoClose()
{
    if (this.InvokeRequired)
    {
        // if this is the background thread then invoke this
        // method on the main thread
        CloseDelegate d = new CloseDelegate(DoClose);
        this.Invoke(d);
    }
    else
    {
        // if it's the main thread ...
        // reduce the opacity gradually until the form disappears
        while (ms_frmSplash.Opacity > 0)
        {
            this.Opacity -= m_dblOpacityDecrement;
            System.Threading.Thread.Sleep(TIMER_INTERVAL);
        }
        this.Close(); // and close the form
    }
}

Change the CloseForm method to read:
C#
static public void CloseForm()
{
    if (ms_frmSplash != null && ms_frmSplash.IsDisposed == false)
    {
        ms_frmSplash.DoClose();
    }
    ms_oThread = null;  // we don't need these any more.
    ms_frmSplash = null;
}

Note also I used the following values:
C#
static int TIMER_INTERVAL = 1 * 1000;  // 1 second sleep timer
double m_dblOpacityIncrement = .1;  // not used
double m_dblOpacityDecrement = .1;  // 10%

[edit]
Updated to use proper cross-thread checking
[/edit]

modified 10-Apr-15 9:09am.

GeneralRe: I can't get my splash screen to close Pin
jkirkerx10-Apr-15 6:46
professionaljkirkerx10-Apr-15 6:46 

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.