Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public void Button1_Click(object sender, EventArgs e)
  2. {
  3. var comWrapper = new COMWrapper(); // A simple wrapper for a COM object
  4.  
  5. Task.Factory
  6. .StartNew(() => LoadStuff(comWrapper))
  7. .ContinueWith(() => {
  8. // Output results...
  9. });
  10. }
  11.  
  12. int LoadStuff(COMWrapper w)
  13. {
  14. return w.LoadStuffFromCOM();
  15. }
  16.  
  17. int LoadStuffFromCOM()
  18. {
  19. string buffer;
  20. IntPtr pointer = Marshal.StringToHGlobalUni(buffer);
  21.  
  22. return comObject.GetValue(pointer); // Exception here...
  23. }
  24.  
  25. initialization
  26. TTypedComObjectFactory.Create(ComServer, TSomeLogic, Class_SomeLogic,
  27. ciMultiInstance, tmFree);
  28. end.
  29.  
  30. initialization
  31. TTypedComObjectFactory.Create(ComServer, TSomeLogic, Class_SomeLogic,
  32. ciMultiInstance, tmApartment);
  33. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement