Lance,
I have found the solution to this issue. It's to do with how you access the libxml for the first time. If you access it from a thread other than the main thread then there can be issues unless xmlInitParser() has been called first. See the following web page.
http://www.xmlsoft.org/threads.html
Is there any chance that you could add a function (e.g. FileGDBAPI::Initialize) that applications could call from the main thread. This function would call xmlInitParser() and any other required initialization.
Here is what I have found related to threading and the FGDB library. I'm using a Java wrapper.
When using the thread monitor 1 I always synchronize on 2 first. That way you avoid deadlocking situations of holding the lock for 2 while getting 1.
FYI with the above strategy I've been able to develop multi-threaded applications with 20 threads that create 400 file GDB files.
Hi Lance,
I am have exactly the same problem mentioned here. I can send you sample application where the problem can be reproduced.
I realized that Geodatabase API C++ is not multi-thread. But as mentioned here if is called from a working thread, the second time for me it would crash. I always make sure that I close the database before starting the second call.
Interestingly, it does NOT crash if I used std:::async() but it does crash if I use AfxBeginThread().
Here is a code snippet.
struct data { Geodatabase m_geodatabase; std::wstring m_name; }; UINT create(LPVOID param) { data *pObject = reinterpret_cast<data*>(param); if (pObject == nullptr) { return 0; } // Create a new geodatabase in the current directory. fgdbError hr; std::wstring errorText; { try { if ((hr = CreateGeodatabase(pObject->m_name, pObject->m_geodatabase)) != S_OK) { ErrorInfo::GetErrorDescription(hr, errorText); return -1; } } catch (...) { } } CloseGeodatabase(pObject->m_geodatabase); delete pObject; pObject = nullptr; return 0; } void CTestGeoDlg::OnBnClickedButton1() { data *d = new data; d->m_name = m_name1; // TODO: Add your control notification handler code here // create( d); std::async(create, d); // AfxBeginThread(create, d); } void CTestGeoDlg::OnBnClickedButton2() { data *d = new data; d->m_name = m_name2; // TODO: Add your control notification handler code here // create( d); std::async(create, d); //AfxBeginThread(create, d); } {
m_name1 and m_name2 are different. The files get created but then crash.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.