Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
передать контрол в backgroundWorker_ProgressChanged
|
|||
|---|---|---|---|
|
#18+
Доброго времени. В обработчике backgroundWorker_DoWork создается объект. Есть необходимость его передать в backgroundWorker_ProgressChanged для добавления в FlowDocument, который находится в Element Host на WinForm. При передаче в обработчик backgroundWorker_ProgressChanged выбрасывается эксепшн "The calling thread cannot access this object because a different thread owns it." Если создавать аналогичным образом например TextBox, то передается нормально... Вот пример кода: Paragraph p = new Paragraph(); p.FontSize = 18; p.FontWeight = FontWeights.Bold; p.Foreground = System.Windows.Media.Brushes.DarkGreen; p.KeepTogether = false; backgroundWorker.ReportProgress(1, p); Подскажите в чем может быть дело ... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.10.2010, 14:49 |
|
||
|
передать контрол в backgroundWorker_ProgressChanged
|
|||
|---|---|---|---|
|
#18+
Using the Dispatcher to Access Controls on Another Thread At times, you may want to change the user interface from a worker thread. For example, you may want to enable or disable buttons, or show a modal ProgressBar that provides more detailed progress information than is allowed by the ReportProgress method. The WPF threading model provides the Dispatcher class for cross thread calls. By using the Dispatcher, you can safely update your user interface from background worker threads. You can get a reference to the Dispacther object for a UI element from its Dispatcher property. System.Windows.Threading.Dispatcher aDisp = Button1.Dispatcher;Dispatcher provides two main methods that you will use; Invoke and BeginInvoke. Both methods allows you to call a method safely on the UI thread. The BeginInvoke method allows you to call a method asynchronously, and the Invoke method allows you to call a method synchronously. From : http://elegantcode.com/2009/07/03/wpf-multithreading-using-the-backgroundworker-and-reporting-the-progress-to-the-ui ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.10.2010, 16:04 |
|
||
|
передать контрол в backgroundWorker_ProgressChanged
|
|||
|---|---|---|---|
|
#18+
Bob Dylan, Да, все верно. Но, в этом случае теряется смысл в фоновом потоке. Т.к. в нем я собирался генерить объекты, а в MainThread добавлять уже в WorkingDocument. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.10.2010, 16:23 |
|
||
|
передать контрол в backgroundWorker_ProgressChanged
|
|||
|---|---|---|---|
|
#18+
ndm25, своими ручками тогда нужно синхронизацию делать, можно, наверное где-нибудь что-то похожее найти и подточить паяльником :) http://www.codeproject.com/KB/cpp/SyncContextTutorial.aspx http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=11 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.10.2010, 16:56 |
|
||
|
|

start [/forum/topic.php?fid=21&msg=36884139&tid=1442640]: |
0ms |
get settings: |
7ms |
get forum list: |
20ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
37ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
37ms |
get tp. blocked users: |
3ms |
| others: | 251ms |
| total: | 371ms |

| 0 / 0 |
