Never Despair
There is so much despair in the world—especially in this area of kedushah. And as we see in the words of the Sfas Emes, despair is part of the klipah that stands in the way of our accessing kedushah. If a person is learning a masechta but falls behind by twenty blatt... to close the Gemara and give up is a childish move. He is still in the game—despite not being perfect. A person must move forward. Daven for siyata diShmaya and continue on—and then you will see success. And be joyful. Be joyful now! Not when you complete the masechta—now! Think now about the siyum, but be joyful now.
Because the more joy one feels during the challenge, the greater will be his good feeling during the battle itself, and the greater will be his ultimate triumph.
Thanking Toward the Future
The idea of being joyful for our future success is no different from the principle that when a person is in a tight spot, in a moment of challenge and difficulty, he should give thanks for the salvation that will come. There are numerous sources for this concept that a person should thank for the future salvation—because this person has such deep emunah in the future salvation that he is already connected to that place in the future, and thus he can already give thanks for it.
This person says: For the Ribbono shel Olam, the past, the present, and the future are all the same... and I choose to connect with the great future that Hashem has in store for me. When he does so, it is an act of avodas Hashem. On Shabbos, we thank Hashem עתיד אתה אשר החסד כל על עמי לעשות, for all the kindness that You will do for me in the future. I give thanks for the future! Because I am a Yid, and I know that the darkness of the present is only a preparation for the light of the future—galus is the actual beginning of the redemption.