apartments

Perform screen-scape of Webbrowser control in thread

早过忘川 提交于 2019-12-17 06:49:33
问题 I am using the technique shown in WebBrowser Control in a new thread Trying to get a screen-scrape of a webpage I have been able to get the following code to successfully work when the WebBrowser control is placed on a WinForm . However it fails by providing an arbitrary image of the desktop when run inside a thread. Thread browserThread = new Thread(() => { WebBrowser br = new WebBrowser(); br.DocumentCompleted += webBrowser1_DocumentCompleted; br.ProgressChanged += webBrowser1

0x80010100: System call failed" exception, ContextSwitchDeadlock

亡梦爱人 提交于 2019-12-12 03:15:02
问题 Long story short: in a C# application that works with COM inproc-server (dll), I encounter "0x80010100: System call failed" exception, and in debug mode also ContextSwitchDeadlock exception. Now more in details: 1) C# app initializes STA, creates a COM object (registered as "Apartment"); then in subscribes to its connection-point, and begins working with the object. 2) At some stage the COM object generates a lot of events, passing as an argument a very big collection of COM objects, which

FreeThreadedDOMDocument, Neutral Apartments and Free-Threaded Marshaler

不羁岁月 提交于 2019-12-11 05:42:27
问题 As MSDN states: If you are writing a single threaded application (or a multi-threaded application where only one thread accesses a DOM at one time), use the rental threaded model (Msxml2.DOMDocument.3.0 or Msxml2.DOMDocument.6.0). If you are writing an application where multiple threads access will simultaneously access a DOM, use the free threaded model (Msxml2.FreeThreadedDOMDocument.3.0 or Msxml2.FreeThreadedDOMDocument.6.0). Is there any connection between FreeThreadedDOMDocument, neutral

C# Marshalling COM objects between threads

≯℡__Kan透↙ 提交于 2019-12-06 07:42:26
问题 I'm getting very confused about whether C# marshal's COM objects between threads. To this end I have an application which is loading a set of files in a task parallel fashion. I'm using the StaTaskScehduler to load the files using the COM object. Once the COM object is loaded I am storing the object in a central list. I then later try to perform some processing on this data, again using the STATaskScheduler. However at this point I hit a problem. I receive an exception as follows: An

C# Marshalling COM objects between threads

北城以北 提交于 2019-12-04 12:58:31
I'm getting very confused about whether C# marshal's COM objects between threads. To this end I have an application which is loading a set of files in a task parallel fashion. I'm using the StaTaskScehduler to load the files using the COM object. Once the COM object is loaded I am storing the object in a central list. I then later try to perform some processing on this data, again using the STATaskScheduler. However at this point I hit a problem. I receive an exception as follows: An unhandled exception of type 'System.Runtime.InteropServices.InvalidComObjectException' occurred in MadCat.exe

Using CoInitializeEx on WinForms threads

落爺英雄遲暮 提交于 2019-11-30 21:24:30
I am working an SDK for a DSLR camera which has the following instructions: Notes on Developing Windows Applications When creating applications that run under Windows, a COM initialization is required for each thread in order to access a camera from a thread other than the main thread. To create a user thread and access the camera from that thread, be sure to execute CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ) at the start of the thread and CoUnInitialize() at the end. Sample code is shown below. This is the same when controlling EdsVolumeRef or EdsDirectoryItemRef objects from another

Using CoInitializeEx on WinForms threads

怎甘沉沦 提交于 2019-11-30 05:38:16
问题 I am working an SDK for a DSLR camera which has the following instructions: Notes on Developing Windows Applications When creating applications that run under Windows, a COM initialization is required for each thread in order to access a camera from a thread other than the main thread. To create a user thread and access the camera from that thread, be sure to execute CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ) at the start of the thread and CoUnInitialize() at the end. Sample code is

Single-Threaded Apartments vs Multi-Threaded Apartments [duplicate]

瘦欲@ 提交于 2019-11-27 18:43:56
Possible Duplicate: Could you explain STA and MTA? All ThreadPool threads are in the multithreaded apartment. --As per the MSDN What does that mean? I am really concerned with what the difference between the multi vs single threaded apartment model is. Or what does the apartment model mean? I have read the MSDN on it, and it doesn't really make sense to me. I think I may have an idea, but I was thinking someone on here could explain it in plain English. Thanks, Anthony D Update 1 Found this Could you explain STA and MTA? Can anyone be more descriptive? Update 2 I am also looking for an answer

Perform screen-scape of Webbrowser control in thread

随声附和 提交于 2019-11-27 01:56:28
I am using the technique shown in WebBrowser Control in a new thread Trying to get a screen-scrape of a webpage I have been able to get the following code to successfully work when the WebBrowser control is placed on a WinForm . However it fails by providing an arbitrary image of the desktop when run inside a thread. Thread browserThread = new Thread(() => { WebBrowser br = new WebBrowser(); br.DocumentCompleted += webBrowser1_DocumentCompleted; br.ProgressChanged += webBrowser1_ProgressChanged; br.ScriptErrorsSuppressed = true; br.Navigate(url); Application.Run(); }); browserThread

Single-Threaded Apartments vs Multi-Threaded Apartments [duplicate]

做~自己de王妃 提交于 2019-11-26 19:34:27
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Could you explain STA and MTA? All ThreadPool threads are in the multithreaded apartment. --As per the MSDN What does that mean? I am really concerned with what the difference between the multi vs single threaded apartment model is. Or what does the apartment model mean? I have read the MSDN on it, and it doesn't really make sense to me. I think I may have an idea, but I was thinking someone on here could