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

CS4014 warning when returning ValueTask instead of Task #2508

Open
BramMusters opened this issue Mar 28, 2025 · 0 comments
Open

CS4014 warning when returning ValueTask instead of Task #2508

BramMusters opened this issue Mar 28, 2025 · 0 comments

Comments

@BramMusters
Copy link

Description

Hangfire throws CS4014 compilation warning when enqueuing async jobs that return ValueTask instead of Task.

Steps to Reproduce

Working case with Task:

public async Task ProcessDataAsync_Task(int id)
{
    // Async operation
    await Task.Delay(100);
    // Process data
}

// Works fine, builds successfully
BackgroundJob.Enqueue(() => ProcessDataAsync_Task(123));

Failing case with ValueTask:

public async ValueTask ProcessDataAsync_ValueTask(int id)
{
    // Async operation
    await Task.Delay(100);
    // Process data
}

// Compiler warning CS4014
BackgroundJob.Enqueue(() => ProcessDataAsync_ValueTask(123));

Expected Behavior

Hangfire should support enqueuing methods that return ValueTask just as it supports methods that return Task, without throwing CS4014 compilation errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant