Unable to update NSProgressIndicator for the dock Icon

I have created a progress indicator to simulate some progressing download task in the dock icon. However, I can see the progress bar appearing in the dock icon but it is not getting updated when I invoked the updateProgress() method. Ideally it should have updated it, and I m not able to figure out the reason?

I have creating the same NSProgressIndicator on an NSWindow and it works to update the progress bar with the same code. Anything that I m missing to understand here? Below is the code I m using:

class AppDelegate: NSObject, NSApplicationDelegate {

    var progressIndicator: NSProgressIndicator!
    let dockTile = NSApp.dockTile

    func applicationWillFinishLaunching(_ notification: Notification) {
                       
        // Step 1: Create a progress bar (NSProgressIndicator)
        progressIndicator = NSProgressIndicator(frame: NSRect(x: 10, y: 10, width: 100, height: 20))
        progressIndicator.isIndeterminate = false 
        progressIndicator.minValue = 0.0
        progressIndicator.maxValue = 100.0
        progressIndicator.doubleValue = 0.0
        progressIndicator.style = .bar
        
        dockTile.contentView = progressIndicator
        dockTile.display()  

        //// Update the progress bar for demonstration
        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
            self.updateProgress(50) 
        }
        
    }
    
    func updateProgress(_ value: Double) {
        
        progressIndicator.doubleValue = value
        NSApp.dockTile.display()  
    }
}

Unable to update NSProgressIndicator for the dock Icon
 
 
Q