Has it always been like this? If so, and if the charger is only small it may only be able deliver enough power to run the laptop, leaving little or none to go into the battery until you shut it down. Certainly it’ll take longer to charge when you’re running it at the same time.
But if this is something new, and especially if the laptop is running slow, you might have something running which is using a lot of processing power. Press ctrl-alt-del and select Task Manager. Look at processor utilisation and see if anything is showing with a continuously high rate. It could be malware such as a browser tab running crypto mining or it could be a legit program running badly. Windows Update sometimes has been known to do this.