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

C#

 
AnswerRe: Personnel IO Pin
Eddy Vluggen21-Apr-13 8:39
professionalEddy Vluggen21-Apr-13 8:39 
GeneralRe: Personnel IO Pin
behrouz shamlo21-Apr-13 11:18
behrouz shamlo21-Apr-13 11:18 
GeneralRe: Personnel IO Pin
Eddy Vluggen21-Apr-13 11:26
professionalEddy Vluggen21-Apr-13 11:26 
GeneralRe: Personnel IO Pin
behrouz shamlo21-Apr-13 19:28
behrouz shamlo21-Apr-13 19:28 
GeneralRe: Personnel IO Pin
Pete O'Hanlon21-Apr-13 21:23
mvePete O'Hanlon21-Apr-13 21:23 
GeneralRe: Personnel IO Pin
Eddy Vluggen21-Apr-13 22:54
professionalEddy Vluggen21-Apr-13 22:54 
Questioncrystal report visual studio 2010 Pin
kalaiselvansurya21-Apr-13 4:17
kalaiselvansurya21-Apr-13 4:17 
QuestionWPF: Add child node to TreeView for other thread Pin
Boltian21-Apr-13 1:41
Boltian21-Apr-13 1:41 
Hello everybody,
I do not what is happened, but I don't know how to do it.
I have a TreeView in the MainWindow and I use another Thread to fill it.
I use Dispacher.BeginInvoke command and the problem is that I obtain the exeption 'The calling thread cannot access this object because a different thread owns it.'
May somebody help me?

The code in the MainWindow Class --------------------------
Here, I call the Thread:
XML
private List<string> gPS = new List<string>();
private List<PSItem> gPSItemsList = new List<PSItem>();
private void bt_PartsViewer_Click(object sender, RoutedEventArgs e)
{
    Microsoft.Win32.OpenFileDialog gOpenFileWindow = new Microsoft.Win32.OpenFileDialog();
    gOpenFileWindow.DefaultExt = ".txt";
    gOpenFileWindow.Filter = "Product Structure|*.txt";
    Nullable<bool> gResult = gOpenFileWindow.ShowDialog();
    if (gResult == true)
    {
        string gFilePath = gOpenFileWindow.FileName;
        gPS = System.IO.File.ReadAllLines(gFilePath).Cast<string>().ToList();
        pb_ProcessProgess.Value = 0;
        Thread gTreeThread = new Thread(new ThreadStart(FillTreeView));
        gTreeThread.SetApartmentState(ApartmentState.STA);
        gTreeThread.Start();
    }
}


The thread call to the method 'FillTreeView'. This method fills a list with TreeViewItems. The list is defined by the variable 'gPSItemsList' from a class (PSItem) inherited from TreeViewItem object.
I want to fill the TreeView with the index 0 of 'gPSItemsList':
C#
private void FillTreeView()
{
    . . .
    LocateTreeItems();

    tv_StructExplorer.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() =>
    {
        tv_StructExplorer.Items.Clear();
        tv_StructExplorer.Items.Add(gPSItemsList[0]); (Here I obtain the exeption about different thread)
    }));
}

The Exeption is not due to 'tv_StructExplorer' object but is for 'gPSItemsList[0]'.

I need help. Thank you.
AnswerRe: WPF: Add child node to TreeView for other thread Pin
Dave Kreskowiak21-Apr-13 4:14
mveDave Kreskowiak21-Apr-13 4:14 
GeneralRe: WPF: Add child node to TreeView for other thread Pin
Boltian6-May-13 6:43
Boltian6-May-13 6:43 
GeneralRe: WPF: Add child node to TreeView for other thread Pin
Dave Kreskowiak6-May-13 7:34
mveDave Kreskowiak6-May-13 7:34 
Questionerro ao fazer um calculo deixando o campo desconto vazio! Pin
Member 1000184520-Apr-13 17:55
Member 1000184520-Apr-13 17:55 
AnswerRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
PIEBALDconsult20-Apr-13 18:04
mvePIEBALDconsult20-Apr-13 18:04 
AnswerRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
OriginalGriff20-Apr-13 21:58
mveOriginalGriff20-Apr-13 21:58 
GeneralRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
Member 1000184524-Apr-13 13:03
Member 1000184524-Apr-13 13:03 
GeneralRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
OriginalGriff24-Apr-13 21:52
mveOriginalGriff24-Apr-13 21:52 
GeneralRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
Member 1000184524-Apr-13 23:42
Member 1000184524-Apr-13 23:42 
GeneralRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
OriginalGriff25-Apr-13 0:19
mveOriginalGriff25-Apr-13 0:19 
GeneralRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
Member 1000184526-Apr-13 11:58
Member 1000184526-Apr-13 11:58 
GeneralRe: erro ao fazer um calculo deixando o campo desconto vazio! Pin
OriginalGriff26-Apr-13 21:39
mveOriginalGriff26-Apr-13 21:39 
QuestionIs monodevelo suitable for a digital pet project in linux? Pin
eleazaro20-Apr-13 10:26
eleazaro20-Apr-13 10:26 
AnswerRe: Is monodevelo suitable for a digital pet project in linux? Pin
jschell21-Apr-13 6:02
jschell21-Apr-13 6:02 
AnswerRe: Is monodevelo suitable for a digital pet project in linux? Pin
Eddy Vluggen21-Apr-13 9:06
professionalEddy Vluggen21-Apr-13 9:06 
Questionexample for using webrequest and webresopnse Pin
arashmousapour20-Apr-13 2:37
arashmousapour20-Apr-13 2:37 
AnswerRe: example for using webrequest and webresopnse Pin
Mycroft Holmes20-Apr-13 13:56
professionalMycroft Holmes20-Apr-13 13:56 

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.