Ticket T965833
Visible to All Users

Should I use the ConnectionHelper.Connect method in multithread applications

created 4 years ago (modified 4 years ago)

[DevExpress Support Team: CLONED FROM T419520: How to troubleshoot the "Reentrancy or cross thread operation detected" error]

HelloDevExpress,
switch from

string connectionString = "Server=tcp:…,1433;Initial Catalog…";
dataLayer = XpoDefault.GetDataLayer(defaultConnectionString, AutoCreateOption.DatabaseAndSchema);

to TheadSafeDataLayer described here: https://docs.devexpress.com/XPO/DevExpress.Xpo.ThreadSafeDataLayer

What about the ConnectionHelper.cs files generated using XPO wizard.
They still have code like

public const string ConnectionString = @"Server=tcp:…,1433;Initial Catalog…";
public static void Connect(DevExpress.Xpo.DB.AutoCreateOption autoCreateOption, bool threadSafe = false)

Regards. Walter.

Answers approved by DevExpress Support

created 4 years ago

Hello Walter,

Do you mean that the Connection Helper does not use the XpoDefault.GetConnectionPoolString method?
This method is not mandatory for a TheadSafeDataLayer. Use it if you want to use a restricted set of database connections in your application. Please refer to the following help topic for additional information: XpoDefault.GetConnectionPoolString(String, Int32, Int32) Method.
Please feel free to reactivate this ticket if I misunderstood your question.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.