MCPcopy Create free account
hub / github.com/HelloBush/Java_MHXYdemo / STA

Class STA

lib/jacob-1.20_src/jacob-1.20/src/com/jacob/com/STA.java:27–101  ·  view source on GitHub ↗

A class that implements a Single Threaded Apartment. Users will subclass this and override OnInit() and OnQuit() where they will create and destroy a COM component that wants to run in an STA other than the main STA.

Source from the content-addressed store, hash-verified

25 * component that wants to run in an STA other than the main STA.
26 */
27public class STA extends Thread {
28 /**
29 * referenced by STA.cpp
30 */
31 public int threadID;
32
33 /**
34 * constructor for STA
35 */
36 public STA() {
37 start(); // start the thread
38 }
39
40 /*
41 * (non-Javadoc)
42 *
43 * @see java.lang.Thread#run()
44 */
45 public void run() {
46 // init COM
47 ComThread.InitSTA();
48 if (OnInit()) {
49 // this call blocks in the win32 message loop
50 // until quitMessagePump is called
51 doMessagePump();
52 }
53 OnQuit();
54 // uninit COM
55 ComThread.Release();
56 }
57
58 /**
59 * Override this method to create and initialize any COM component that you
60 * want to run in this thread. If anything fails, return false to terminate
61 * the thread.
62 *
63 * @return always returns true
64 */
65 public boolean OnInit() {
66 return true;
67 }
68
69 /**
70 * Override this method to destroy any resource before the thread exits and
71 * COM in uninitialized
72 */
73 public void OnQuit() {
74 // there is nothing to see here
75 }
76
77 /**
78 * calls quitMessagePump
79 */
80 public void quit() {
81 quitMessagePump();
82 }
83
84 /**

Callers

nothing calls this directly

Calls 1

loadJacobLibraryMethod · 0.95

Tested by

no test coverage detected