Click here to Skip to main content
15,905,867 members
Home / Discussions / C#
   

C#

 
RantRe: What is best way? Pin
Nagy Vilmos16-Oct-08 3:06
professionalNagy Vilmos16-Oct-08 3:06 
Questiongot problem with sequence of event execution Pin
Krazy Programmer16-Oct-08 2:37
Krazy Programmer16-Oct-08 2:37 
AnswerRe: got problem with sequence of event execution Pin
Guffa16-Oct-08 3:17
Guffa16-Oct-08 3:17 
GeneralRe: got problem with sequence of event execution Pin
Krazy Programmer16-Oct-08 19:44
Krazy Programmer16-Oct-08 19:44 
GeneralRe: got problem with sequence of event execution Pin
Guffa17-Oct-08 13:38
Guffa17-Oct-08 13:38 
GeneralRe: got problem with sequence of event execution Pin
nelsonpaixao16-Oct-08 12:36
nelsonpaixao16-Oct-08 12:36 
GeneralRe: got problem with sequence of event execution Pin
Krazy Programmer16-Oct-08 19:44
Krazy Programmer16-Oct-08 19:44 
QuestionThreads and WinForms Pin
Programm3r16-Oct-08 1:45
Programm3r16-Oct-08 1:45 
Hi all,

A while ago I posted a question on this topic, and received a great response. I made use of the article posted by Sacha Barber called Beginners Guide To Threading In .NET Part 5 of n. In this article he uses the SynchonizationContext to marshall the background work to the UI thread.

But the thing is that when I send response back to a listview on the GUI thread x amount of time in quick succession the whole application just freezes / hangs.

Is this a bad idea doing it like this or am I just doing something wrong (maybe a different approach)

private SynchronizationContext context;
.....
.....
//set up the SynchronizationContext
context = SynchronizationContext.Current;
if (context == null)
{
    context = new SynchronizationContext();
}
.....            
.....            
try
{
    for (int i = 0; i < (int)e.Argument; i++)
    {
        context.Send(new SendOrPostCallback(delegate(object state)
        {
            lViewTransactionHistory.Items.Add(lViewTransactionHistory.Items.Count.ToString(), DateTime.Now.ToLongTimeString(), 0);

        }), null);
    }
}
catch (InvalidOperationException oex)
{
    MessageBox.Show(oex.Message);
}



The only programmers that are better those C# programmers are those who code in 1's and 0's Green Alien | [Alien]



Smile | :) Programm3r

My Blog: ^_^

AnswerRe: Threads and WinForms Pin
Alan N16-Oct-08 1:59
Alan N16-Oct-08 1:59 
GeneralRe: Threads and WinForms Pin
Programm3r16-Oct-08 2:03
Programm3r16-Oct-08 2:03 
QuestionRe: Threads and WinForms Pin
Programm3r16-Oct-08 2:13
Programm3r16-Oct-08 2:13 
AnswerRe: Threads and WinForms Pin
Giorgi Dalakishvili16-Oct-08 2:30
mentorGiorgi Dalakishvili16-Oct-08 2:30 
GeneralRe: Threads and WinForms Pin
Programm3r16-Oct-08 2:49
Programm3r16-Oct-08 2:49 
QuestionRe: Threads and WinForms Pin
Programm3r16-Oct-08 3:05
Programm3r16-Oct-08 3:05 
AnswerRe: Threads and WinForms Pin
Giorgi Dalakishvili16-Oct-08 3:19
mentorGiorgi Dalakishvili16-Oct-08 3:19 
GeneralRe: Threads and WinForms Pin
Programm3r16-Oct-08 3:25
Programm3r16-Oct-08 3:25 
GeneralRe: Threads and WinForms Pin
Giorgi Dalakishvili16-Oct-08 3:31
mentorGiorgi Dalakishvili16-Oct-08 3:31 
GeneralRe: Threads and WinForms Pin
Programm3r16-Oct-08 3:39
Programm3r16-Oct-08 3:39 
GeneralRe: Threads and WinForms Pin
Giorgi Dalakishvili16-Oct-08 5:44
mentorGiorgi Dalakishvili16-Oct-08 5:44 
QuestionHow to change the height property of panel dynamically Pin
mharoonkhan16-Oct-08 1:04
mharoonkhan16-Oct-08 1:04 
AnswerRe: How to change the height property of panel dynamically Pin
EliottA16-Oct-08 2:08
EliottA16-Oct-08 2:08 
QuestionC# Print DataGridView Pin
Socheat.Net15-Oct-08 23:42
Socheat.Net15-Oct-08 23:42 
AnswerRe: C# Print DataGridView Pin
Giorgi Dalakishvili15-Oct-08 23:53
mentorGiorgi Dalakishvili15-Oct-08 23:53 
RantRe: C# Print DataGridView Pin
Nagy Vilmos16-Oct-08 3:11
professionalNagy Vilmos16-Oct-08 3:11 
AnswerRe: C# Print DataGridView Pin
Dave Kreskowiak16-Oct-08 3:45
mveDave Kreskowiak16-Oct-08 3:45 

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.