Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No events are fired when SQLTabledependency is stared in a task #255

Open
stevensrf11 opened this issue Oct 31, 2024 · 0 comments
Open

No events are fired when SQLTabledependency is stared in a task #255

stevensrf11 opened this issue Oct 31, 2024 · 0 comments

Comments

@stevensrf11
Copy link

stevensrf11 commented Oct 31, 2024

I am running the SQLTabledependency in a task
After the SQLTabledependency is started a manual reset event waits till it get signals.
No SQLTabledependency events get fired.
How come.
public virtual async Task SqlDependencyAsync(
// public virtual Task SqlDependencyAsync(
, ManualResetEvent taskEndEvent
, string connectionString
, string tableName
, string schemaName

   )
    {
        try
        {

            using (var tableDependency = new SqlTableDependency<PrintQueueSqlDependency>(connectionString
                       , tableName
                       , schemaName
                       , null
                       , null
                       , null
                       , DmlTriggerType.All
                       , false))
            {

                tableDependency.OnChanged += TableDependencyOnChange;
                tableDependency.OnError += TableDependencyOnError;
                tableDependency.OnStatusChanged += TableDependencyOnStatusChanged;
                await taskEndEvent.ManualResetAsyncExtension();
                // taskEvent.WaitOne();
            }
        }
        catch (TableDependency.SqlClient.Exceptions.ImpossibleOpenSqlConnectionException ex)
        {
            IsRunningError = "Failed to run SQLTable Dependency. Could not connect to database";
        );
        }
        catch (Exception ex)
        {
            IsRunningError =$"Failed to run SQLTable Dependency. { ex.Message}";
           
        }
        
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant