class LinkedDataAdmin(admin.ModelAdmin):
raw_id_fields = ('secondary', 'primary')
list_select_related = ('secondary', 'primary')
class Meta:
model = LinkedData
admin.site.register(LinkedData, LinkedDataAdmin)
'The calling thread cannot access this object because a different thread owns it.'
private void LoadDataToDB_Click(object sender, RoutedEventArgs e)
{
StatusBar.Style = LoadBarStyle;
Mouse.OverrideCursor = Cursors.Wait;
Thread thread = new Thread(RunAnalyzerThread);
thread.SetApartmentState(ApartmentState.STA);
thread.Name = "AnalyzerThread";
thread.Start();
Mouse.OverrideCursor = Cursors.Arrow;
StatusBar.Style = normalBarStyle;
}
public void RunAnalyzerThread()
{
Analyzer analyzer = new Analyzer();
analyzer.LoadDataInDB(this);
}
if (запрос к бд == true) {
DataBase.ClearAll();
Task.Factory.StartNew(async () => {//изменение
DirectoryInfo info = new DirectoryInfo(@"path\Data\");
DirectoryInfo[] dirs = info.GetDirectories();
for (int r = 0; r < dirs.Length; r++) {
var additionalLines = File.ReadAllLines(@"path\Data\" + dirs[r].Name + @"\
Additional.txt "); ~ 10000строк
var mainLines = File.ReadAllLines(@"pathr\Data\" + dirs[r].Name + @"\
Main.txt "); ~ 18000строк
for (int i = 0; i < mainLines.Length; i++) {
DataMain data = new DataMain();
int markCounter = 0;
string word = string.Empty;
for (int j = 0; j < mainLines[i].Length; j++) {
char symbol = mainLines[i][j];
await Application.Current.Dispatcher.InvokeAsync(() => {//изменение
mainWindow.maxLines = mainLines.Length.ToString();
mainWindow.currentLine = i.ToString();
mainWindow.ChangeLineData();
});
}