Diet. Go for periods of time without eating, or eating half of what you ordinarily eat. Then BINGE. (not bulemia type binging, do NOT NOT NOT stuff yourself, but eat rich nutrient rich foods at odd times or only 3 meals a day with the heavy one being the last one before bed, instead of the healthy way of eating 5-6 small meals a day, and then start eating healthy amounts 5-6 times a day). Diet typically about 4 times per year. Diet for a 2 weeks - 1 month, binge for a couple weeks, eat healthily (not dieting) for 3. The dieting that most people do to LOSE weight is what triggers your body to hoard calories. In the beginning of dieting you lose weight, but then the weight stacks itself on like crazy. Eating almost constantly, otoh, while working out, and you'll gain weight to begin with, but then your body will start releasing calories like crazy. If you trick your body into going into "starvation mode" you can pack on weight like crazy.
ALSO follow weightlifter guides. EAT A TON OF PROTEIN right after working out. My husband does 4,000 calorie shakes right after lifting (so gross... protein powder, icecream, and peanut butter... makes me want to gag. Sometimes he'll add in chocolate syrup, too. Ugh). When you get a sudden influx of protein after tearing muscle your body shunts those amino acids straight to the muscles. You get stronger and more stamina a lot faster. It doesn't matter whether you're doing weight lifting (to pack on muscle) or aerobic exercise/yoga (to pack on muscle)... whether you're going for bulk or strong clean lines... the protein and calories right after spending is *exactly* what bodies need. I joke and think of it as "hunt your prey and eat it".
As an overweight anorexic (yah yah I should be happy about the added weight, I'm not), TRUST ME, gaining and losing has sooooo much more to do with nutrition and eating patterns over time than daily calorie intake. Calories are just a SMALL piece of the puzzle. At one point I was eating a max of 400 calories a day while hiking 10 miles AND dancing for 6 hours every day. And gaining weight. (can we say "murdered metabolism"?). It's taken YEARS of making sure that my intake/expenditure is as equal as possible to even be able to be healthy again / allow my body to send nutrients where they belong.
Also, as an anorexic (myself, I have no idea if you are, how could I? Lots of people are underweight and NOT anorexic), work with your doctor/nutritionist and DON'T do anything ANYONE SAYS (including me!:) without running over the science behind it *for your particular case* with them!!! Horror story, I *listened* to someone telling me I needed to up my exercise when I was finally gaining, and had a heart attack because my heart hadn't healed enough yet. Later on, that advice was dead on accurate, but in my case... I hadn't healed enough yet from being too low.