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.