Click here to Skip to main content
15,888,984 members
Home / Discussions / C#
   

C#

 
AnswerRe: Deleting Read Bytes Pin
OriginalGriff11-May-14 0:49
mveOriginalGriff11-May-14 0:49 
GeneralRe: Deleting Read Bytes Pin
computerpublic11-May-14 5:58
computerpublic11-May-14 5:58 
GeneralRe: Deleting Read Bytes Pin
OriginalGriff11-May-14 6:22
mveOriginalGriff11-May-14 6:22 
GeneralRe: Deleting Read Bytes Pin
Richard MacCutchan11-May-14 7:17
mveRichard MacCutchan11-May-14 7:17 
GeneralRe: Deleting Read Bytes Pin
Richard MacCutchan11-May-14 7:17
mveRichard MacCutchan11-May-14 7:17 
QuestionHow Do I Select Particular Data From Sql Database In C#? Pin
hahaahahaahahhahahahhahaha10-May-14 18:29
hahaahahaahahhahahahhahaha10-May-14 18:29 
AnswerRe: How Do I Select Particular Data From Sql Database In C#? Pin
OriginalGriff10-May-14 21:31
mveOriginalGriff10-May-14 21:31 
QuestionUpdating UI from Task Pin
GrooverFromHolland10-May-14 5:40
GrooverFromHolland10-May-14 5:40 
Hi All,

In a tutorial I found a a new way (new for me)of updating a control from a thread.

In the example code the new way(AsyncParallel) is in button1_Click and what I am familiar with is in button2_Click.
They both do the job, but what is better, regarding performance and especially when more tasks are running that might update UI-thread?

Here is the example:
namespace Task_Compare
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            string data = "";
            Task Tf1 = Task.Factory.StartNew(() =>
                                  {
                                      data = GetData();
                                  });

            Task T2 = Tf1.ContinueWith((previousTask) =>
                                   {
                                      listBox1.Items.Insert(0, data);
                                   }, TaskScheduler.FromCurrentSynchronizationContext());

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string data = "";
            Task Tf2 = Task.Factory.StartNew(() =>
                                    {
                                        data = GetData();
                                    });
            Tf2.Wait();

            listBox1.Invoke(new EventHandler(delegate
            {
                listBox1.Items.Insert(0, data);
            }));
        }

        private string GetData()
        {
            string temp = "";
            {
                temp = " Do something long running ......";
            }

            return temp;
        }
    }
}


Groover,
0200 A9 23
0202 8D 01 80
0205 00

AnswerRe: Updating UI from Task Pin
Eddy Vluggen12-May-14 8:31
professionalEddy Vluggen12-May-14 8:31 
GeneralRe: Updating UI from Task Pin
GrooverFromHolland13-May-14 10:31
GrooverFromHolland13-May-14 10:31 
GeneralRe: Updating UI from Task Pin
Eddy Vluggen14-May-14 7:19
professionalEddy Vluggen14-May-14 7:19 
QuestionEditing values in List? Pin
Member 1044193910-May-14 4:16
professionalMember 1044193910-May-14 4:16 
AnswerRe: Editing values in List? Pin
Wes Aday10-May-14 4:25
professionalWes Aday10-May-14 4:25 
AnswerRe: Editing values in List? Pin
pradeep surya10-May-14 5:19
pradeep surya10-May-14 5:19 
AnswerRe: Editing values in List? Pin
Member 1044193910-May-14 6:33
professionalMember 1044193910-May-14 6:33 
AnswerRe: Editing values in List? Pin
Wes Aday10-May-14 14:08
professionalWes Aday10-May-14 14:08 
AnswerRe: Editing values in List? Pin
BillWoodruff10-May-14 13:31
professionalBillWoodruff10-May-14 13:31 
AnswerRe: Editing values in List? Pin
Emre Ataseven11-May-14 7:05
professionalEmre Ataseven11-May-14 7:05 
QuestionError : Expected class,delegate,enum, interface,or struct Pin
Member 104511519-May-14 16:02
Member 104511519-May-14 16:02 
AnswerRe: Error : Expected class,delegate,enum, interface,or struct Pin
BillWoodruff9-May-14 16:44
professionalBillWoodruff9-May-14 16:44 
QuestionError : Expected class,delegate,enum, interface,or struct Pin
Member 104511519-May-14 16:01
Member 104511519-May-14 16:01 
AnswerRe: Error : Expected class,delegate,enum, interface,or struct Pin
Richard MacCutchan9-May-14 21:38
mveRichard MacCutchan9-May-14 21:38 
QuestionI want to learn how to make in C# only Stock bar chart Pin
Member 107434229-May-14 11:47
Member 107434229-May-14 11:47 
AnswerRe: I want to learn how to make in C# only Stock bar chart Pin
Garth J Lancaster9-May-14 13:20
professionalGarth J Lancaster9-May-14 13:20 
GeneralRe: I want to learn how to make in C# only Stock bar chart Pin
Member 107434229-May-14 14:46
Member 107434229-May-14 14: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.