Mobile edge computing (MEC) has emerged as a promising solution for addressing the growing computational demands by enabling cloud computing capabilities at the network edge. However, existing MEC models typically make assumptions of known processing cycles and uninterrupted communications, which are not practical in real-world scenarios. This paper aims to tackle the challenges posed by uncertainties and intermittent communications in MEC systems in the context of task offloading. We first derive a closed-form expression for the average offloading success probability in a device-to-device (D2D) assisted MEC system. This expression accurately accounts for uncertain computation processing cycles and intermittent communications. Then, we formulate the task offloading maximization problem (TOMP) and prove its NP-hardness. For problem-solving, we propose two algorithms tailored to different scenarios. In instances exhibiting a uniform structure, we introduce a task scheduling algorithm based on dynamic programming (TSDP). When dealing with general scenarios, we reformulate the problem and propose a repeated matching algorithm (RMA). We use Monte Carlo simulations to validate the closed-form expression. The results demonstrate that gap between them is less than 0.55%, confirming the accuracy of the closed-form expression. Furthermore, the proposed algorithms outperform other algorithms by performance comparison.