0

I am using background worker thread and Observable collection .The problem is i am declared property in main thread as follows:

 public ObservableCollection<IpMacAddressClass> ipmac { get; set; }

But i need to update this collection under background worker DoWork process.Now it is giving me following error:

This type of CollectionView does not support changes to its SourceCollection from a 
thread different from the Dispatcher thread.

My code is below:

var item = new IpMacAddressClass();
string pattern = @"(F8-F7-D3-00\S+)";
Match matchmac = Regex.Match(_stringData, pattern);

string pattern2 = @"(192.168.1\S+)";
Match matchip = Regex.Match(_stringData, pattern2);

while (matchmac.Success && matchip.Success)
{
    item._ip = matchip.Value;
    Console.WriteLine("IP Address : {0}", matchip.Value);
    item._mac = matchmac.Value;
    Console.WriteLine("MAC Address : {0}", matchmac.Value);

    matchmac = matchmac.NextMatch();
    matchip = matchip.NextMatch();
    ***ipmac.Add(item);***
}

I want to know how to solve this issue .Any help would be greatly appreciable.

hennes
  • 9,147
  • 4
  • 43
  • 63
CodeTheft
  • 91
  • 1
  • 9
  • possible duplicate of [Dispatcher throws InvalidOperationException on Messagebox.Show in Textchanged event](http://stackoverflow.com/questions/7442943/dispatcher-throws-invalidoperationexception-on-messagebox-show-in-textchanged-ev) – thumbmunkeys Oct 18 '14 at 11:58
  • then see the duplicate link – thumbmunkeys Oct 18 '14 at 12:08

0 Answers0