Let $A$ be an unbunded operator with densely domain $D(A)$ in a Hilbert space $H$.
Is it true that $A$ commutes with Riemann integral? that is :
For any Riemann integrable function $f : [a,b] \to H$ such that $f(x)\in D(A),\; \forall x\in [a,b],$ we have: $$ A\int_a^b f(x) dx=\int_a^b Af(x) dx $$
As an example, let $f(x) = \chi_{[a,x]}$, which defines a continuous function from $[a,b]$ into $H=L^2[a,b]$. Then $$ \left.\int_{a}^{b}f(x)dx\right|_{t} = \int_{t}^{b}dx=(b-t). $$ The resulting function is nicely differentiable. You can consider $A=\frac{d}{dt}$ on the dense domain $\mathcal{D}(A)$ consisting of all absolutely continuous $f \in L^2$ for which $f' \in L^2$. That defines a closed densely-defined operator $A$ for which $\int_{a}^{b}f(x)dx \in \mathcal{D}(A)$, but such that $f(x) \notin \mathcal{D}(A)$ for all $a < x < b$.
If $f(x) \in \mathcal{D}(A)$ is Riemann integrable, and if $Af(x)$ is also Riemann integrable, then $$ A\sum_{\mathscr{P}}f(x_j^*)\Delta x_j=\sum_{\mathscr{P}}(Af)(x_j^*)\Delta x_j, $$ and both sides converge as $\|\mathscr{P}\|\rightarrow 0$. The result follows as you want because $A$ is closed and $$ \sum_{\mathscr{P}}f(x_j^*)\Delta x_j\rightarrow \int_a^b f(x)dx, \\ A\sum_{\mathscr{P}}f(x_j^*)\Delta x_j \rightarrow \int_a^b (Af)(x)dx. $$ The above then shows that $\int_{a}^{b}f(x)dx \in \mathcal{D}(A)$ and $$ A\left(\int_{a}^{b}f(x)dx\right) = \int_{a}^{b}(Af)(x)dx. $$